ASP.NET MVC - IsPostBack 还在吗? [英] ASP.NET MVC - Is IsPostBack still here?

查看:16
本文介绍了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 母版页上有一个网络表单用户控件,可以启动回发.我正在尝试通过 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天全站免登陆