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"); 
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top