簡體   English   中英

ASP.NET Web應用程序不會自動重定向到Default.aspx

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

我有一個空的ASP.NET Web應用程序設置來為我們的團隊提供NuGet存儲庫。 我將其創建為一個空的Web應用程序,除了將NuGet.Server程序包添加到解決方案並將測試程序包添加到Packages目錄之外,沒有做太多其他事情。

我已將該應用程序發布到IIS,驗證我的目標是正確的框架(4.0),並仔細閱讀了有關該主題的所有文章。 我找不到解決方法。 基本上,當我轉到http://locoalhost/NuGet_Test ,我希望重定向到http://localhost/NuGet_Test/Default.aspx ,但是不會發生。 我可以直接轉到http://localhost/NuGet_Test/Default.aspx ,一切正常。 但是我不知道為什么它沒有達到默認值。 我很擔心,因為如果將來其他Web應用程序發生這種情況,我不知道該怎么辦。

另外,我已經驗證了default.aspx在IIS(7.0)的“默認文檔”列表中。

更好的嘗試

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

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

更新:這是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