You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在IIS托管的PHP网站中创建ASP.NET虚拟目录后访问出现404错误求助

Troubleshooting the 404 Error for Your ASP.NET Virtual Directory in IIS

Hey, let's walk through the most likely issues and fixes for that 404 error you're getting when accessing your ASP.NET virtual directory under the PHP site in IIS:

1. Verify the Virtual Directory's Physical Path

  • Double-check that the physical path set for your virtual directory in IIS points exactly to the wwwroot/ASP.NET Web应用程序 folder. It's easy to mistype the path or select the wrong parent folder during setup—even a small error will make IIS fail to locate your ASP.NET files.
  • To confirm: Right-click the virtual directory → Edit Virtual Directory → Ensure the physical path matches your actual folder structure perfectly (keep an eye on capitalization too, even Windows is case-insensitive, IIS can be finicky in some scenarios).

2. Check Application Pool Permissions & Identity

  • You've set the pool to .NET 4.0 Integrated mode, but let's make sure the pool's identity has the right permissions to access your ASP.NET folder. The default ApplicationPoolIdentity might not have enough access—try temporarily switching the pool's identity to LocalSystem (just for testing, switch back to a more secure identity later) and refresh the site to see if the 404 goes away.
  • Also, verify the NTFS permissions on your ASP.NET folder: Add the user IIS AppPool/[Your Application Pool Name] and grant it Read & Execute permissions (not just Read/Write—ASP.NET needs execute rights to compile and run code).

3. Configure Default Documents for the Virtual Directory

  • IIS might not be looking for your ASP.NET app's default page when you access the virtual directory directly. If your app uses Default.aspx, Index.aspx, or another custom homepage, you need to add it to the default documents list.
  • Steps: Open the virtual directory's Default Documents feature → Click Add, enter your homepage filename, and move it to the top of the list so IIS prioritizes it.

4. Check for URL Rewrite Conflicts from the PHP Site

  • If your PHP site uses URL rewriting (common with frameworks like WordPress, Laravel, etc.), the rewrite rules might be intercepting requests to your ASP.NET virtual directory, causing IIS to return a 404.
  • Look for a web.config file in your PHP site's root folder. If it exists, add an exclusion rule for your virtual directory before any other rewrite rules:
<rule name="Exclude ASP.NET Virtual Directory" stopProcessing="true">
  <match url="^[Your Virtual Directory Name]/.*" />
  <action type="None" />
</rule>

This tells IIS to skip rewriting requests targeting your ASP.NET directory.

5. Re-register ASP.NET 4.0 with IIS

  • Even if you set the application pool to .NET 4.0, ASP.NET might not be properly registered with IIS on your server. Open an elevated Command Prompt (run as administrator) and run these commands:
    For 32-bit systems:
    %windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
    
    For 64-bit systems (run both):
    %windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
    %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
    
    After running, restart IIS with the iisreset command and test again.

6. Convert the Virtual Directory to an Application

  • Make sure your virtual directory is configured as an ASP.NET application in IIS. If it's just a regular virtual directory, IIS won't treat it as a standalone ASP.NET app. Right-click the virtual directory → Convert to Application, select your .NET 4.0 application pool, and confirm.

内容的提问来源于stack exchange,提问作者MARKAND Bhatt

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:49:32