简体   繁体   中英

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. 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.

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. 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. I can go to http://localhost/NuGet_Test/Default.aspx directly and everything displays fine. 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.

Also, I have verified that default.aspx is in the Default Documents list on 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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