IIS 10 访问Visual Studio Web应用出现404错误求助
default.aspx in Your IIS-Hosted Web App Hey there, let's work through this 404 issue you're facing—since static resources load fine but default.aspx doesn't, we can narrow down the problem to how IIS handles ASP.NET pages or default document settings. Here's a step-by-step breakdown to fix this:
1. Verify Default Document Configuration
Static files are accessible, but IIS might not be recognizing default.aspx as a valid default page.
- Open IIS Manager, navigate to your target site.
- Double-click the Default Document feature.
- Check if
default.aspxis in the list. If not, click Add and enterdefault.aspx. - Use the Move Up button to give it higher priority than other default docs (like
index.html) so IIS checks it first.
2. Re-register ASP.NET with IIS
After reinstalling Windows, the ASP.NET runtime might not be properly registered with IIS, which breaks processing of .aspx files.
- Open Command Prompt as Administrator.
- Run the appropriate command based on your .NET Framework version:
- For .NET Framework 4.x (32-bit):
%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i - For .NET Framework 4.x (64-bit):
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
- For .NET Framework 4.x (32-bit):
- Restart IIS after running the command with
iisreset.
3. Validate Visual Studio Project Settings
Ensure your project is correctly mapped to IIS:
- Right-click your project in Visual Studio → Properties.
- Go to the Web tab.
- Under Servers, confirm Local IIS is selected, and the Project URL matches your
localhostsetup (e.g.,http://localhost/YourAppName). - Click Create Virtual Directory to refresh the mapping between your project files and IIS.
4. Check File & Folder Permissions
Even if the path looks correct, IIS's application pool identity might lack access to default.aspx:
- Navigate to your project's physical folder on disk.
- Right-click the folder → Properties → Security tab.
- Click Edit → Add, then enter
IIS_IUSRSin the object name field and click Check Names to confirm. - Grant the
IIS_IUSRSgroup Read & Execute, List folder contents, and Read permissions.
5. Inspect IIS Handler Mappings
Make sure IIS has the correct handler to process .aspx files:
- In IIS Manager, go to your site and double-click Handler Mappings.
- Look for entries like
PageHandlerFactory-Integrated(for Integrated pipeline mode) orPageHandlerFactory-ISAPI-4.0_32bit/64bit. - If these entries are missing, re-register ASP.NET using the command from step 2—it should restore these mappings.
6. Disable URL Rewrite Rules (If Applicable)
If you have URL Rewrite installed, a misconfigured rule might be blocking default.aspx:
- In IIS Manager, open the URL Rewrite feature for your site.
- Temporarily disable all rules (right-click → Disable Rule) and test accessing
default.aspxagain. If it works, you'll need to adjust the problematic rule.
After trying these steps, test accessing http://localhost/default.aspx directly—if it loads, you've fixed the issue. If not, double-check that your default.aspx file exists in the root of your site's physical path (not in a subfolder).
内容的提问来源于stack exchange,提问作者Starcrusher

