Asp.net mvc 在MVC中向不同的主机提交表单

Asp.net mvc 在MVC中向不同的主机提交表单,asp.net-mvc,form-submit,hidden-field,Asp.net Mvc,Form Submit,Hidden Field,我在Razor视图中实现了一个操作链接,如下所示 <input type="hidden" id="format"/> @Html.ActionLink("Save", "SaveFile", "ExportService", "http", "hrmsapp.mysystem.com", "", new { fileformat = <hidden field value here> }, new { @id = "save" }) @ActionLink(“Sa

我在Razor视图中实现了一个操作链接,如下所示

<input type="hidden" id="format"/>

@Html.ActionLink("Save", "SaveFile", "ExportService", "http", "hrmsapp.mysystem.com", "", new { fileformat = <hidden field value here> }, new { @id = "save" })

@ActionLink(“Save”、“SaveFile”、“ExportService”、“http”、“hrmsapp.mysystem.com”、“new{fileformat=}、new{@id=“Save”})
我需要在参数“fileformat”中将隐藏字段的值传递给此操作链接

我找不到任何方法来做这件事。有很多帖子都在谈论@使用带有“post”方法的Html.Form。然而,当我拥有不同的域名hrms.mysystem.com时,我不知道如何使用表单发布。在Html.Form中没有用于此目的的重载

有没有办法读取操作链接代码本身中的隐藏字段值(不使用表单)?


@Html.Form所做的就是打印Html。你不必使用它。您只需使用指向不同服务器的操作硬编码HTML表单,然后发布它。



@Html.Form所做的就是打印Html。你不必使用它。您可以使用指向不同服务器的操作硬编码HTML表单,然后发布它。

您可以使用jQuery替换占位符字符串:

<input type="hidden" id="format"/>

@Html.ActionLink("Save", "SaveFile", "ExportService", "http", "hrmsapp.mysystem.com", "", new { fileformat = "xxfileformat" }, new { @id = "save" })

<script>
    $(function() {
        $('#save').attr('href', $('#save').attr('href').replace('xxfileformat', $('#format').val()))
    });
</script>

@ActionLink(“Save”、“SaveFile”、“ExportService”、“http”、“hrmsapp.mysystem.com”、“new{fileformat=“xxfileformat”}、new{@id=“Save”})
$(函数(){
$('#save').attr('href',$('#save').attr('href').replace('xxfileformat',$('#format').val())
});

您可以使用jQuery替换占位符字符串:

<input type="hidden" id="format"/>

@Html.ActionLink("Save", "SaveFile", "ExportService", "http", "hrmsapp.mysystem.com", "", new { fileformat = "xxfileformat" }, new { @id = "save" })

<script>
    $(function() {
        $('#save').attr('href', $('#save').attr('href').replace('xxfileformat', $('#format').val()))
    });
</script>

@ActionLink(“Save”、“SaveFile”、“ExportService”、“http”、“hrmsapp.mysystem.com”、“new{fileformat=“xxfileformat”}、new{@id=“Save”})
$(函数(){
$('#save').attr('href',$('#save').attr('href').replace('xxfileformat',$('#format').val())
});

是的,你说得对!在这种情况下,在哪里传递控制器和操作名称?另外,在您的示例中,有两次提到action属性。我猜这是方法而不是操作?如果这是inter server,则无法基于控制器和操作名称生成路径,因为一个ASP.NET应用程序不知道另一个的结构。它只会在所有东西布线之前看到图层,就像在浏览器上一样。不幸的是,您必须对完整路径进行硬编码。@AnilSoman,很抱歉,第二个操作应该是
method
。我已经更新了答案。至于控制器/动作,Pluc是正确的。你必须硬编码完整的URL,包括协议。@danludwig:太酷了。成功了!非常感谢。:)普鲁克-谢谢!是的,你说得对!在这种情况下,在哪里传递控制器和操作名称?另外,在您的示例中,有两次提到action属性。我猜这是方法而不是操作?如果这是inter server,则无法基于控制器和操作名称生成路径,因为一个ASP.NET应用程序不知道另一个的结构。它只会在所有东西布线之前看到图层,就像在浏览器上一样。不幸的是,您必须对完整路径进行硬编码。@AnilSoman,很抱歉,第二个操作应该是
method
。我已经更新了答案。至于控制器/动作,Pluc是正确的。你必须硬编码完整的URL,包括协议。@danludwig:太酷了。成功了!非常感谢。:)普鲁克-谢谢!