मैंने नियंत्रक को पोस्ट करने के बाद RedirectToAction
का उपयोग करने का प्रयास किया लेकिन यूआरएल नहीं बदला और रीडायरेक्ट काम नहीं कर रहा है। मुझे यह जोड़ने की ज़रूरत है कि जब मैं डीबग करता हूं तो रीडायरेक्ट नियंत्रक एक्शन विधि में प्रवेश करता है। यह URL बदल नहीं करता है या Index
दृश्य पर जाएं, ...रीडायरेक्ट टॉक्शन काम नहीं कर रहा है
public ViewResult Index()
{
return View("Index",new TrainingViewModel());
}
public ActionResult Edit()
{
//save the details and return to list
return RedirectToAction("Index");
}
क्या मैं गलत कर रहा हूँ?
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.js/{*pathInfo}");
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
}
// jQuery कॉल फ़ायरबग साथ
this.SynchValuesToReadOnly = function() {
window.location = $('#siteRoot').attr('href') + 'Sites/';
};
this.OnSiteEdit = function() {
//post back to the server and update the assessment details
var options = {
target: '',
type: 'post',
url: '/Site/Edit',
beforeSubmit: othis.validate,
success: othis.SynchValuesToReadOnly
};
$('#uxSiteForm').ajaxSubmit(options);
};
आपके द्वारा दिखाया गया कोड सही है। मेरा जंगली अनुमान यह है कि आप एक मानक पोस्ट नहीं कर रहे हैं (उदाहरण के लिए, रीडायरेक्ट AJAX पोस्ट के साथ काम नहीं करते हैं)। क्या आप अधिक कोड दिखा सकते हैं? –
aaaaahhh .... उसे नहीं पता था। हाँ आप सही है।यह वास्तव में jquery में AJAX पोस्ट से आ रहा है और इसका मतलब है कि अगर सफल हो तो मुझे वहां से रीडायरेक्ट करना चाहिए। कोई समस्या नहीं। अपनी टिप्पणी को 'उत्तर' के रूप में रखें और जब मैं धन्यवाद – kurasa