2011-03-04 58 views
1

我在MVC 3網站上使用jQuery Mobile。除了我有一個鏈接到返回RedirectResult的控制器操作的標籤以外,運行良好。它看起來像jQuery攔截鏈接,每次都出錯。我收到移動框架輸出的標準「發生錯誤」消息。用Firebug檢查響應顯示響應完全是空的。jQuery Mobile不支持MVC RedirectResult

我聽說可能有一個數據屬性,我需要添加到標記,使移動用戶界面忽略它?任何想法或其他解決方案?

編輯:爲了說明問題,URL正在正確生成,並且是一個有效的URL,它與jQUery mobile攔截請求的方式有關。

<a href='/[email protected]["URL"]' title="view full site" >view full site</a> 

public RedirectResult FullSite() 
       { 
        StringBuilder redirectUrl = new StringBuilder("http://www.site.com/"); 

        try 
        { 
         string referringUrl = Request.QueryString["p"]; 

         if (!String.IsNullOrEmpty(referringUrl) && referringUrl.Contains("photo-gallery")) 
          referringUrl = referringUrl.Replace(@"/photo-gallery", String.Empty); 

         redirectUrl.Append(referringUrl); 
        } 
        catch (Exception) 
        { 
         redirectUrl.Clear(); 
         redirectUrl.Append("http://www.site.com"); 
        } 

        CookieManager.SetMobileToFullSiteCookie(); 
        return new RedirectResult(redirectUrl.ToString()); 
       } 

回答

2

我使用rel="external"強制鏈接加載爲正常請求,而不是使用AJAX。

<a href='/fullsite?pRequest.ServerVariables["URL"]' 
    rel="external" 
    title="view full site" >view full site</a> 

您還可以使用data-ajax="false"target設置一個值,請參閱1.0a3下的文檔在http://jquerymobile.com/demos/1.0a3/docs/pages/link-formats.html

+0

這工作,謝謝。 – Scott 2011-03-04 18:40:09

+0

我想我更喜歡data-ajax。似乎更多的jQuery手機。 :) – Scott 2011-03-04 18:44:28

+0

@Scott,對於你想重新加載的實際內部鏈接,我同意。我的用例實際上是一個外部鏈接,'rel =「external」'更符合語義。 – tvanfosson 2011-03-04 18:46:31