母版页和视图中的表单 [英] Forms in MasterPage and Views

查看:56
本文介绍了母版页和视图中的表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个主页,我的所有视图都继承自该主页.我遇到的问题是在母版页中创建的表单标签,然后是在视图中创建的表单标签.

I have a master page which all my views inherit from. The issue I am having is with the form tag which is created in the master page and then the form tag which is created in view.

由于该表单位于母版页表单中,因此我所有的回发都发送到控制器的Index方法,并且它迫使我创建一个新方法Index来强制执行HttpPost.

Because of the form being inside the master page form, all my postbacks are sent to the controllers Index method and its forcing me to create a new method Index which forces an HttpPost.

此外,这还会引起路由问题,例如/projects/add/和/projects/delete/1,其中的所有内容都路由到索引方法.

Further this is causing problems with routes like: /projects/add/ and /projects/delete/1 where everything is router to the Index Method.

WTF?我在这里想念东西吗?

WTF? Am i missing something here?

谢谢任何人

推荐答案

从母版页中删除表单.

此处中查看一些示例视频,以更好地理解MVC理念.

Check some sample videos here to better understand the MVC philosophy.

顺便说一句:在ASP.NET MVC中,没有回发.

BTW: In ASP.NET MVC, there is no postback.

这篇关于母版页和视图中的表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆