Html.BeginForm不会重定向到操作方法

时间:2022-12-06 21:42:17

I try using Html.BeginForm to submit my data but it does not help me with it. I followed this link to make my mvc program: https://www.c-sharpcorner.com/UploadFile/f82e9a/form-data-submiting-and-displaying-data-another-view-using-m/

我尝试使用Html.BeginForm来提交我的数据,但它对我没有帮助。我按照这个链接制作我的mvc程序:https://www.c-sharpcorner.com/UploadFile/f82e9a/form-data-submiting-and-displaying-data-another-view-using-m/

@using (Html.BeginForm("SubmitEmp","ClientController",FormMethod.Post))

using this I get the following error:

使用此我收到以下错误:

Html.BeginForm不会重定向到操作方法

My view has a folder named Client, in which there are two files:

我的视图有一个名为Client的文件夹,其中有两个文件:

  1. Index: this contains the form.
  2. 索引:这包含表单。

  3. this the view to get the details entered in the previous form. My controller (ClientController) has the code mentioned in the link and my Model is Cmodel with the same code.
  4. 这是用于获取在上一个表单中输入的详细信息的视图。我的控制器(ClientController)有链接中提到的代码,我的Model是Cmodel,代码相同。

3 个解决方案

#1


0  

Your Code should be like this then it will work

您的代码应该是这样的,然后它才会起作用

@using (Html.BeginForm("SubmitEmp","Client",FormMethod.Post))

We cannot and use full controller name like ClientController for specifying controller name we need to specify only the name of Client

我们不能使用像ClientController这样的完整控制器名来指定我们只需要指定Client名称的控制器名称

In your URL localhost:5000/ClientController/Submitemp showing controller name ClientController it should be Client only change your URL like localhost:5000/Client/Submitemp then it will work.

在您的URL localhost:5000 / ClientController / Submitemp显示控制器名称ClientController它应该是客户端只更改您的URL像localhost:5000 / Client / Submitemp然后它将工作。

Cheers!!

#2


0  

No need to pass "Controller" in controller name, simply pass "Client". Make sure you have "SubmitEmp" HttpPost action in Client Controller

无需在控制器名称中传递“Controller”,只需传递“Client”即可。确保在Client Controller中有“SubmitEmp”HttpPost操作

#3


0  

I can see that you have passed controller name as 'ClientController' which appears to be incorrect. The Controller in 'ClientController' represents that this is a Controller named Client. You can pass 'Client' instead of 'ClientController' in the place for controller.

我可以看到你已经将控制器名称作为'ClientController'传递,这似乎是不正确的。 “ClientController”中的Controller表示这是一个名为Client的Controller。您可以在控制器的位置传递“Client”而不是“ClientController”。

#1


0  

Your Code should be like this then it will work

您的代码应该是这样的,然后它才会起作用

@using (Html.BeginForm("SubmitEmp","Client",FormMethod.Post))

We cannot and use full controller name like ClientController for specifying controller name we need to specify only the name of Client

我们不能使用像ClientController这样的完整控制器名来指定我们只需要指定Client名称的控制器名称

In your URL localhost:5000/ClientController/Submitemp showing controller name ClientController it should be Client only change your URL like localhost:5000/Client/Submitemp then it will work.

在您的URL localhost:5000 / ClientController / Submitemp显示控制器名称ClientController它应该是客户端只更改您的URL像localhost:5000 / Client / Submitemp然后它将工作。

Cheers!!

#2


0  

No need to pass "Controller" in controller name, simply pass "Client". Make sure you have "SubmitEmp" HttpPost action in Client Controller

无需在控制器名称中传递“Controller”,只需传递“Client”即可。确保在Client Controller中有“SubmitEmp”HttpPost操作

#3


0  

I can see that you have passed controller name as 'ClientController' which appears to be incorrect. The Controller in 'ClientController' represents that this is a Controller named Client. You can pass 'Client' instead of 'ClientController' in the place for controller.

我可以看到你已经将控制器名称作为'ClientController'传递,这似乎是不正确的。 “ClientController”中的Controller表示这是一个名为Client的Controller。您可以在控制器的位置传递“Client”而不是“ClientController”。