简体   繁体   English

ASP.NET Web应用程序不会自动重定向到Default.aspx

[英]ASP.NET Web Application Does not Autoredirect to Default.aspx

I have an empty ASP.NET Web application set up to serve a NuGet repository to our team. 我有一个空的ASP.NET Web应用程序设置来为我们的团队提供NuGet存储库。 I created it as an empty web application and didn't do much else except add the NuGet.Server package to the solution and add a test package to the Packages directory. 我将其创建为一个空的Web应用程序,除了将NuGet.Server程序包添加到解决方案并将测试程序包添加到Packages目录之外,没有做太多其他事情。

I've published the application to IIS, verified that I'm targeting the right framework (4.0), and looked through all the posts I can find on the topic. 我已将该应用程序发布到IIS,验证我的目标是正确的框架(4.0),并仔细阅读了有关该主题的所有文章。 I haven't been able to find a fix. 我找不到解决方法。 Basically, when I go to http://locoalhost/NuGet_Test , I expect to get redirected to http://localhost/NuGet_Test/Default.aspx , but it doesn't happen. 基本上,当我转到http://locoalhost/NuGet_Test ,我希望重定向到http://localhost/NuGet_Test/Default.aspx ,但是不会发生。 I can go to http://localhost/NuGet_Test/Default.aspx directly and everything displays fine. 我可以直接转到http://localhost/NuGet_Test/Default.aspx ,一切正常。 But I don't know why it's not going to the default. 但是我不知道为什么它没有达到默认值。 I'm concerned because I don't know what to do if this happens with other web applications in the future. 我很担心,因为如果将来其他Web应用程序发生这种情况,我不知道该怎么办。

Also, I have verified that default.aspx is in the Default Documents list on IIS (7.0). 另外,我已经验证了default.aspx在IIS(7.0)的“默认文档”列表中。

better yet, try this.. 更好的尝试

protected void Application_Start(object sender, EventArgs e)
{
    RegisterRoutes(RouteTable.Routes);
}

public static void RegisterRoutes(RouteCollection routes)
{
    routes.MapPageRoute("", "/NuGet_Test","~/Default.aspx");
}

UPDATE: This was the actual solution tmoore used, no extra method & slight change in the URL form...thanks tmoore 更新:这是tmoore所使用的实际解决方案,没有多余的方法,并且URL形式略有更改...感谢tmoore

protected void Application_Start(object sender, EventArgs e)
{
    var routeCollection = RouteTable.Routes;  routeCollection.MapPageRoute("DefaultRoute", string.Empty, "~/Default.aspx"); 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM