2012-02-24 66 views
0

我正在開發MVC3項目,並有這種情況。只在運行時。RedirectToAction在運行時

我使用默認的帳戶控制器登錄。如果登錄成功,我需要重定向到剛剛somethhing這樣的另一個領域:

   if (Membership.ValidateUser(model.UserName, model.Password)) 
      { 
       FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); 
       SessionBag.Current.UserName = model.UserName; 
       if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") 
        && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) 
       { 
        return Redirect(returnUrl); 
       } 
       else 
       { 
        //Here This doesn´t work at run time. 
        return RedirectToAction("MenuInicial", "Menu", new { area = "Configuration" }); 
       } 
      } 
      else 
      { 
       ModelState.AddModelError("", "The user name or password provided is incorrect."); 
      } 

它運行在開發時確定,但之後發佈該網站無法正常工作。

我的第一個環節(它顯示了歡迎,並提供一個登錄按鈕)

[HTTP://本地主機/ mobile1]

點擊logonButton後: [HTTP://本地主機/ mobile1#/Mobile1 /帳號/ LogOn支持]

型用戶名和密碼後,它說 加載頁面時出錯

如果manullay更改鏈接

[http:// localhost/mobile1#/ Mobile1/Account/LogOn]到[localhost/mobile1/Account/LogOn] 發生同樣的錯誤。

非常感謝您的幫助。

回答

1

這是一個安全問題,ActionResult的需要編寫一些文件..

它解決了impersonatting背景下的一些窗戶正確權限的文件夾中的文件需要編寫有效的用戶。

在部分的System.Web web.config中添加

<system.web> 
    .... 
    <identity impersonate="true" 
      userName="username" 
      password="userpassword"/>   
</system.web>