RedirectToAction不SurfaceController正常工作? [英] RedirectToAction is not working correctly in SurfaceController?
问题描述
我米submiting一种形式SurfaceController的行动提交。其中,数据保存后重定向到另一个动作LeadContact使用MVC RedirectToAction并通过ID作为参数设置为它。在LeadContact模式正在被填充,并传递给'LeadContact视图。
不知道是否我米正确与否做,但是当LeadContact呈现在浏览器,它修改了URL。浏览器显示的URL,比如的http://名称:50656 /一把umbraco /面/ HealthInsurance / LeadContact leadOptionId = 70
而我米期待它应该是
的http://名称:50656 / HealthInsurance / LeadContact leadOptionId = 70
能否请您指导我可以纠正吗?下面是我的code:
公众的ActionResult提交(的FormCollection形式)
{ //一些逻辑和后重定向到另一个动作LeadContact返回RedirectToAction(LeadContact,新的{leadOptionId = _id});
}
公众的ActionResult LeadContact(INT leadOptionId) {
MyViewModel模式=新MyViewModel(); // $ C $行C数据填充到模型 返回视图(LeadContact模型);
}
感谢您的帮助和分享。
添加以下重写规则配置\\ UrlRewriting.config:
<添加名称=LeadContactRewrite
virtualUrl =^ / HealthInsurance / LeadContact(。*)
rewriteUrlParameter =ExcludeFromClientQueryString
目标网址=〜/一把umbraco /面/ HealthInsurance / LeadContact?$ 1
IGNORECASE =真/>
回收IIS,你应该能够去的http://名称:?50656 / HealthInsurance / LeadContact leadOptionId = 70
,并得到您想要的结果。
您也可以考虑在一把umbraco 自定义MVC路由p>
I m submiting a form to SurfaceController's action 'Submit'. Where after saving data it Redirect to another action 'LeadContact' using MVC RedirectToAction and pass Id as a paramter to it. In 'LeadContact' model is being populating and passed to 'LeadContact' view.
Not sure if I m doing correctly or not but when 'LeadContact' renders in browser it amends URL. Browser shows URL like http://name:50656/umbraco/Surface/HealthInsurance/LeadContact?leadOptionId=70
while I m expecting it should be
http://name:50656/HealthInsurance/LeadContact?leadOptionId=70
Can you please guide I can correct it ? Below is my code:
public ActionResult Submit(FormCollection form)
{
//Some logic and later redirect to another action 'LeadContact'
return RedirectToAction("LeadContact", new { leadOptionId = _id});
}
public ActionResult LeadContact(int leadOptionId)
{
MyViewModel model = new MyViewModel();
//Lines of code to populate data into model
return View("LeadContact", model);
}
Thanks for your help and sharing.
Add the following rewrite rule to config\UrlRewriting.config:
<add name="LeadContactRewrite"
virtualUrl="^/HealthInsurance/LeadContact(.*)"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/umbraco/Surface/HealthInsurance/LeadContact?$1"
ignoreCase="true" />
Recycle IIS and you should be able to go to http://name:50656/HealthInsurance/LeadContact?leadOptionId=70
and get your desired outcome.
You could also look into Custom MVC routing in Umbraco
这篇关于RedirectToAction不SurfaceController正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!