ASP.NET MVC - 是的IsPostBack还在这里? [英] ASP.NET MVC - Is IsPostBack still here?

查看:148
本文介绍了ASP.NET MVC - 是的IsPostBack还在这里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,我知道,我知道。我不应该做的MVC里面的WebForms,我完全同意。但是,谁签我的薪水的人不会马上批准我们的网站,MVC的完全转化。所以我采取渐进的步骤,一页一页,将它们转换过,而在MVC增加新的功能。

I know, I know, I know. I shouldn't be doing webforms inside of MVC, I completely agree. But, the people who sign my paycheck will not approve a complete conversion of our site to MVC right now. So I am taking incremental steps, page by page, to convert them over while adding new features in MVC.

所以我的问题是如何从一个控制器访问IsPostBack属性?

So my question is how can I access the IsPostBack property from a controller?

编辑:为了进一步澄清,我有我的MVC母版页上一个WebForm用户控制,可以启动回发。我试图找出这些经文回发一个MVC职位。在这一点上我觉得我要只检查申请表键为__VIEWSTATE键,如果它的发现把它作为一个回发。

To further clarify, I have a webform user control on my mvc master page which can initiate postbacks. I'm trying to identify these postbacks verses an mvc post. At this point I think I am going to just check the request form keys for a "__viewstate" key and if its found treat it as a postback.

推荐答案

在任何情况下仍然有兴趣,你可以测试从里面像这样的MVC操作方法一个POST:

In case anyone is still interested, you can test for a POST from inside an MVC Action Method like this:

if (Request.HttpMethod=="POST") { 

}

这篇关于ASP.NET MVC - 是的IsPostBack还在这里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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