2017-06-08 51 views
0

我有一個完全開發的MVC應用程序,它具有使用自定義成員資格的登錄功能。 我的客戶端有一個經典的asp.net應用程序,必須具有自己的登錄功能(沒有確切的登錄細節可能是簡單的數據庫用戶允許登錄或Windows身份驗證)從經典的asp.net應用程序打開mvc應用程序

客戶端應用程序將有一個按鈕,點擊哪個應該重定向到我的mvc應用程序/ somecontroller/someaction

我已經嘗試了正常編碼如下,但應用程序不重定向。

protected void btnConfig_Click(object sender, EventArgs e) 
     { 
      string mywebUrl = System.Configuration.ConfigurationManager.AppSettings["mywebUrl"]; 
      //It is like localhost:9108 

      /* I have tried setting cookie same way as it is set in my mvc app */ 

      //string cookiedata = "admin"; 
      //string userData = string.Empty; 
      //var expiretime = DateTime.Now.Add(FormsAuthentication.Timeout); 
      //FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, cookiedata, DateTime.Now, expiretime, false, userData); 
      //string encTicket = FormsAuthentication.Encrypt(authTicket); 
      //HttpCookie formAuthCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket); 
      //Response.Cookies.Add(formAuthCookie); 

      Response.Redirect(mywebUrl + "/Home/Index", true); 
     } 
+0

據我所知,你不能從一個應用程序重定向到另一個,除非它們是由同一個應用程序池來管理,或者您提供一些手段來會話數據傳輸上,並在另一個網站上創建一個會話。只需打開另一個帶有URL的瀏覽器窗口,如果您只想顯示該網站......但無法重定向響應! – Wheels73

+0

「app不重定向」是什麼意思?究竟發生了什麼? – JustAndrei

+0

您的mywebUrl設置中是否指定了模式? – JustAndrei

回答

0

此按鈕點擊代碼是在asp.net應用程序中我想從哪裏打開MVC應用程序。 我犯了一個非常愚蠢的錯誤。

protected void btnConfig_Click(object sender, EventArgs e) 
    { 
     Response.Redirect("http://localhost:5555" + "/Home/Index"); 
     // I was missing http:// in my url 
    } 
+0

哈哈...非常好...很高興你有它排序! – Wheels73

+0

這就是我問你的:「你的mywebUrl設置中指定了模式嗎?」 – JustAndrei

相關問題