2013-07-11 4 views
8

से अधिक है, मैं एक दृश्य पर रीडायरेक्ट करने का प्रयास कर रहा हूं और प्रश्न शीर्षक में पोस्ट प्राप्त कर रहा हूं।इस अनुरोध के लिए क्वेरी स्ट्रिंग की लंबाई कॉन्फ़िगर किए गए maxQueryStringLength मान

ब्रेकपॉइंट परीक्षण के दौरान कोड को पास करने के दौरान कोड iv के पहले बिट को संदेश सेट करने और अपवाद सेट करने के नीचे नीचे रखना पड़ा। रिटर्न रीडायरेक्ट के बाद जारी रखने के बाद निम्नलिखित अगले पृष्ठ प्रदर्शित होते हैं।

enter image description here

ErrorController को तोड़ने के अंक और त्रुटि मॉडल जोड़ना मैंने पाया कि कोड वहाँ कभी नहीं हो जाता है।

जिस दृश्य को मैं पोस्ट करने का प्रयास कर रहा हूं वह एक त्रुटि पृष्ठ है। समस्या देखने में आपकी सहायता के लिए यहां कोड है।

RedirectToAction:

string message; 
message = "An error has occured during the communication to lightstone, this is likely a timeout issue and could be the result of a bad connection. Please go back and try again."; 
return RedirectToAction("Error", "Error", new { ex = ex.ToString(), message = message}); 

मेरी ErrorController में कार्रवाई:

public ActionResult Error(string ex, string message) 
{ 
    ViewBag.Message = "Error"; 
    return View(new ErrorModel(ex, message)); 
} 

मेरे त्रुटि मॉडल:

namespace MvcResComm.Models 
{ 
    public class ErrorModel 
    { 
     public string ex { get; set; } 
     public string message { get; set; } 

     public ErrorModel(string ex, string message) 
     { 
      this.ex = ex; 
      this.message = message; 
     } 
    } 
} 
+0

आप http://stackoverflow.com/questions/8159321/request-exceeds-the-configured-maxquerystringlength-when-using- उत्तर के लिए प्राधिकृत कर सकते हैं। –

+0

अब मैं समस्या को समझता हूं, लेकिन अभी भी इसे ठीक करने के लिए कोई समाधान समाधान नहीं है। – Pomster

उत्तर

4

आप TempData का उपयोग क्यों नहीं करते हैं, यह इस तरह की चीजें करने का मतलब है। तो उदाहरण के लिए:

TempData["ErrorMessage"] = "An error has occured during the communication to lightstone, this is likely a timeout issue and could be the result of a bad connection. Please go back and try again."; 

यह link देखें।

संपादित

इस तरह अपने अपवाद संदेश दर्रा:

TempData["Error"] = ex.Message(); 
TempData["ErrorMessage"] = "An error has occured during the communication to lightstone, this is likely a timeout issue and could be the result of a bad connection. Please go back and try again."; 

return RedirectToAction("Error", "Error"); 

तो बस इसे अपने ErrorController से, की तरह कुछ का उपयोग:

public ActionResult Error(string ex, string message) 
{ 
    var error = (string)TempData["Error"]; 
    // do other magic ... 
} 
+0

में काम करता है धन्यवाद, मैं यह सुनिश्चित कर दूंगा, लेकिन मुझे लगता है कि त्रुटि त्रुटि नियंत्रक से पहले त्रुटि है। त्रुटि रीडायरेक्ट से कार्रवाई करने के लिए होती है। – Pomster

+0

@Pomster क्षमा करें मैं स्पष्ट नहीं था, मेरे संपादन की जांच करें। मुझे उम्मीद है यह मदद करेगा। –

+0

@ पोम्स्टर, असल में, मैंने इसका परीक्षण नहीं किया, लेकिन मुझे पूरा यकीन है कि आप इसे सीधे देखने के लिए पास कर सकते हैं (मेरा मतलब है कि आप सीधे अपने विचार में 'TempData ["error"]' तक पहुंच सकते हैं, आप नहीं करते इसे पास करना होगा)। –

1

एक maxumum URL लंबाई मूल्य वेब में settable नहीं है। विन्यास फाइल इस प्रश्न में एक ही समस्या है ASP.NET MVC, Url Routing: Maximum Path (URL) Length

+0

त्रुटि को रीडायरेक्ट से क्रिया में त्रुटि होती है? यूआरएल की लंबाई का असर क्यों होगा? – Pomster

+0

क्योंकि यूआरएल लंबाई जीईटी अनुरोध के आकार पर परिभाषित सीमा है। ऐसा पहले ब्राउज़र के लिए समर्थन सुनिश्चित करने के लिए किया जाता है जो एक निश्चित आकार पर यूआरएल लंबाई को संभाल नहीं सकता है। जब आप किसी एक्शन (कंट्रोलर पर) पर रीडायरेक्ट करते हैं तो यह उस क्रिया पर मिलता है –

+0

धन्यवाद ठीक है, अब मैं देखता हूं, फिर मैं इन स्ट्रिंग्स को एक नियंत्रक से कैसे पास करूंगा जहां त्रुटि नियंत्रक को त्रुटि होती है, बाहर निकलने के साथ यह यूआरएल में? या मैं अधिकतम यूआरएल आकार कैसे सेट करूं? Pomster

1

आप वेब में।config <system.web> <httpRuntime> टैग के अंतर्गत आप MSDN संदर्भ बाहर अपने maxQueryStringLength

इसलिए इसकी तरह

<system.web> 
    <httpRuntime 
     <maxQueryStringLength = "**MY NUMBER**" /> 
    /> 
</system.web 

जांच सेट कर सकते हैं: http://msdn.microsoft.com/en-us/library/e1f13641%28v=vs.100%29.aspx

इसके अलावा IIS कॉन्फ़िगरेशन में maxQueryStringLength वृद्धि कृपया देखें:

http://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits

+0

आईवी इसे बड़ी संख्या में सेट करें और कुछ भी नहीं हुआ है? – Pomster

+0

संख्या कितनी बड़ी है? –

+0

Pomster

11

अपनी परियोजना के लिए जड़ web.config में, system.web नोड के अंतर्गत:

<system.web> 
    <httpRuntime maxUrlLength="10999" maxQueryStringLength="2097151" /> 
... 

इसके अलावा, मैं system.webServer नोड के अंतर्गत जोड़ने के लिए था या मैं अपने लंबे क्वेरी स्ट्रिंग के लिए एक सुरक्षा त्रुटि मिली:

<system.webServer> 
    <security> 
     <requestFiltering> 
     <requestLimits maxUrl="10999" maxQueryString="9999" /> 
     </requestFiltering> 
    </security> 
... 
संबंधित मुद्दे