我正在开发一个具有以下属性的项目:
Asp.net
C# 
.Net Framework 4
IIS 7
在其中,我使用Application_BeginRequest来手动重写,如下所示:
void Application_BeginRequest(object sendet, EventArgs e)
    {
        bool IsUploading = System.Configuration.ConfigurationManager.AppSettings["IsUloading"] == "1";
        if (Request.Headers["X-Requested-With"] == "XMLHttpRequest")
        {
            return;
        }
        string Path = Request.RawUrl;
        string QueryString = "";
        if (Request.QueryString.Count != 0)
        {
            string[] u = Path.Split(new char[] { '?' });
            Path = u[0];
            QueryString = u[1];
        }
        string url = "";
        if (Path.EndsWith(".css") || Path.EndsWith(".js") || Path.EndsWith(".png") || Path.EndsWith(".jpg") || Path.EndsWith(".jpeg") || Path.EndsWith(".bmp") || Path.EndsWith(".htm") || Path.EndsWith(".png") || Path.EndsWith(".gif") || Path.EndsWith(".fla") || Path.EndsWith(".swf") || Path.EndsWith(".axd") || Path.EndsWith(".xml") || Path.EndsWith(".ashx"))
            return;
        if (!Path.EndsWith("/"))
            Path += "/";
        IEnumerator<string> Part = Path.Split(new char[] { '/' }).AsEnumerable<string>().GetEnumerator();
        if (Part.MoveNext() && Part.MoveNext())
        {
            if (Part.Current == "")
                url = "Default.aspx";
            else if (Part.Current.ToLower() == "public")
            {
                if (Part.MoveNext() && Part.Current.ToLower() == "install")
                    url = "Public/Install.aspx";
                else
                    url = "Public/PageNotFound.aspx";
            }
            else
                url = "Public/PageNotFound.aspx";
        }
        else
            url = "Public/PageNotFound.aspx";
        if (url.Contains("?"))
            Context.RewritePath("~/" + url + "&" + QueryString);
        else
            Context.RewritePath("~/" + url + "?" + QueryString);
    }
现在当尝试浏览页面时localhost:97,浏览器开始打开 Default.aspx 但是如果我尝试打开localhost:97/Public/Install浏览器给我这个错误:
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
哪里出错了?!!!
UPDATE1:当我尝试浏览时localhost:97/Public/Install,VS 不会在我在此事件中放置的断点处停止。我认为我的请求在 IIS 中被拒绝。
UPDATE2:我知道我的代码是 100% 正确的,因为我们正在使用 TFS 服务器,而另一台计算机对此没有任何问题,只是我的计算机遇到了这个问题。
对不起我的英语不好。我是新的。更详细的评论我。