2011-11-18 26 views
1

配置IIS 6.0運行的應用程序MVC3配置IIS 6.0運行的應用程序MVC3

我想我有我的IIS 6服務器上的配置問題,我想看看是否有什麼我已經錯過了。

我遇到的問題是,隨時當一個RedirectToAction(「索引」,「家」)執行(例如在一個方法返回一個ActionResult)我期望我會返回到:

http://servername.domain.com/virtualdirectoryname 

但是,相反,我重定向到:

http://servername.domain.com/virtualdirectoryname/virtualdirectoryname 

追加到URL的末尾virtualdirectoryname的第二個實例,不能找出爲什麼 - 這個網址當然會產生404資源n沒有發現錯誤。我在企業Intranet和公共Internet環境中編寫和部署了幾個MVC3應用程序,但無法弄清楚我做錯了什麼。我的global.asax.cs似乎確定 -

public class MvcApplication : System.Web.HttpApplication 
{ 
    public static void RegisterGlobalFilters(GlobalFilterCollection filters) 
    { 
     filters.Add(new HandleErrorAttribute()); 
    } 

    public static void RegisterRoutes(RouteCollection routes) 
    { 
     routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 

     routes.MapRoute(
      "Default", // Route name 
      "{controller}/{action}/{id}", // URL with parameters 
      new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults 
     ); 
    } 

    protected void Application_AuthenticateRequest(Object sender, EventArgs e) 
    { 
     if (HttpContext.Current.User != null) 
     { 
      if (HttpContext.Current.User.Identity.IsAuthenticated) 
      { 
       if (HttpContext.Current.User.Identity is FormsIdentity) 
       { 
        FormsIdentity id = (FormsIdentity)HttpContext.Current.User.Identity; 
        FormsAuthenticationTicket ticket = id.Ticket; 

        // Get the stored user-data, in this case, our roles 
        string userData = ticket.UserData; 
        string[] roles = userData.Split(','); 
        HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(id, roles); 
       } 
      } 
     } 
    } 

    protected void Application_Start() 
    { 
     AreaRegistration.RegisterAllAreas(); 

     RegisterGlobalFilters(GlobalFilters.Filters); 
     RegisterRoutes(RouteTable.Routes); 
    } 
} 

的Application_AuthenticateRequest處理對登錄用戶角色的存儲,但除此之外,似乎很香草。我能想到的唯一想法是,我已經搞砸了虛擬目錄。

在執行這些步驟之前,我已經驗證了.NET框架的MVC3和v4.0安裝在服務器上。此服務器上還有其他ASP.NET 4.0應用程序正在無故運行。在這臺服務器上運行的還有一個MVC2應用程序(也安裝了MVC2),並且一直運行正常。

  1. 我使用IIS管理器創建了主「默認站點」之外的虛擬目錄。
  2. 在該虛擬目錄指向的文件夾上設置適當的權限。使用快速的「Hello,World」index.html文件進行測試。
  3. 將我的開發PC上的應用程序複製到應用程序開發的位置,然後運行到#2中所述的文件夾。
  4. 更新了Web.Config文件,編輯連接字符串以指向測試數據庫服務器;我還在我的開發PC上驗證了這些連接字符串。
  5. 打開網頁瀏覽器,並希望最好。

任何援助非常感謝。

謝謝!

回答

1

我想你可能會看到的是:

http://servername.domain.com/virtualdirectoryname/applicationname 

如果您已經命名自己的虛擬目錄相同的名稱作爲您的應用程序,然後我可以看到怎麼會迷惑你。如果你沒有虛擬目錄,只是你的應用程序在你會看到默認Web站點的根目錄:

http://servername.domain.com/applicationname 

是您的虛擬目錄相同的名稱作爲您的應用程序的名稱?如果是這樣,那就是你看到這個的原因。

+0

但問題是http://servername.domain。com/virtualdirectoryname/virtualdirectoryname導致404資源未找到錯誤。 –

+0

轉到IIS中的應用程序並右鍵單擊它並選擇「瀏覽」。瀏覽器中的URL是什麼樣的? – 2011-11-18 21:22:17

+0

servername.domain.com/virtualdirectoryname/virtualdirectoryname –

相關問題