【发布时间】:2015-04-08 18:16:15
【问题描述】:
我已将 MVC 应用程序发布到服务器路径“/iapps/ebiz”。该应用程序在本地主机上完美运行。 @Ajax.Action 链接在“Get”操作中按预期工作,但“”没有找到控制器的 Post 方法,并抛出错误代码 404。
@Ajax.ActionLink(
"Add Email",
"GetEditEmail","Customer",
new { CommunicationLocation = "add" },
new AjaxOptions()
{
HttpMethod = "Get",
UpdateTargetId = "DivEmailContainer",
InsertionMode = InsertionMode.Replace
},
new { @class = "btn btn-success" }) </td>
@using (Html.BeginForm("PostEditEmail","Customer", FormMethod.Post, new { name = "frmEmail", id = "frmEmail" }))
{
<input type="submit" value="Save" class="btn btn-success" />
<!-- This one is going "/iapps/Customer" but suppose to be "/iapps/eBiz/Customer"
}
控制器
[HttpGet]
public PartialViewResult GetEditEmail(string CommunicationLocation)
{
}
[HttpPost]
[Route("PostEditEmail")]
public PartialViewResult PostEditEmail(string Actiontype, FormCollection col)
{
}
路线图
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Customer", action = "Index", id = UrlParameter.Optional }
);
HTML 显示
<form action="/iapps/ebiz/Customer/PostEditEmail?Length=8" data-ajax="true" data-ajax-method="Post" data-ajax-mode="replace" data-ajax-update="#DivEmailContainer" id="frmEmail" method="post" name="frmEmail" novalidate="novalidate" _lpchecked="1">
更新:2015 年 4 月 8 日下午 3:30
如果我在浏览器中的 eBiz 之后添加 /eBiz/(反斜杠),则问题已修复。如果/eBiz 和帖子不起作用。如何解决这个问题?
此尾随斜杠表示基本 url 问题。
【问题讨论】:
-
你创建的虚拟目录路径是ebiz吗
标签: c# asp.net ajax asp.net-mvc asp.net-mvc-4