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.
So my question is how can I access the IsPostBack property from a controller?
Edit: 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.
You can use this piece of code in Razor
If you have more than one form in an MVC page, you can add a hidden input within the form with a meaningful ID and test if it has a value. This way you do not need to have two separate handlers (one for get and one for post).
So inf the page and inside the form:
And in the controller :
Hope it helps!
In case anyone is still interested, you can test for a POST from inside an MVC Action Method like this:
The MVC framework doesn't support the classic postback and viewstate used in the Web forms. So, no, you don't have access to the IsPostBack.
My advice to you is to have two branches: one with the current site where you're adding patches for known errors and another one where you build a new site from scratch. New features should be implemented in this one. I assume that most of your codebase is re-usable in the new site.
When the new site is ready, put it in production.
I would definitely take a look at this blog post by Scott Hanselman where he puts an aspx page in a MVC application.
http://www.hanselman.com/blog/PlugInHybridsASPNETWebFormsAndASPMVCAndASPNETDynamicDataSideBySide.aspx
Your controllers will not have access to the ViewState property. Even if you did want to handle the problem of __VIEWSTATE, you would have to do some work in order to get it into a usable form in an mvc controller. Good luck on coming up with a conversion strategy, no matter how it works out a lot of people would be interested to know kind of problems you would face in the process.
I'm not sure if I understood your question correctly, but on the controller you would have an action that handles the initial GET from the browser and a second action to handle POSTs.