Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 28, 2013 10:19 PM by teahou
Jan 28, 2013 09:02 PM|LINK
I have a form I built in MVC. Somehow it is throwing a 'can cast int to string' error after the user clicks the 'Submit' button on the form, but BEFORE it hits the action method in the controller. So the error is occuring in this wierd limbo space.
So I need someway of seeing what values are flying through the ether after submitted, but before hitting the controller.
I tried putting a 'BeginRequest' in the global asax because I thought is supposed to be called before each action:
protected void Application_BeginRequest()
I put a breakpoint on the first curly bracket, and it does work as far as that goes, but it seems I need to put something in the BeginRequest method to actually read the values, becuase it stops on the beginrequest, but as soon as I hit the 'go into' button
on the debugger, it goes through and errors out again, before going to the controller.
So, any ideas of what I can put in the method to grab the values?
Jan 28, 2013 09:06 PM|LINK
omehow it is throwing a 'can cast int to string' error after the user clicks the 'Submit' button on the form, but BEFORE it hits the action method in the controller
That right. You can have a custom model binder - or just put string instead of int - and make the conversion yourself.
Jan 28, 2013 09:18 PM|LINK
True, but one thing I didn't mention is, the error message and stck trace give me no indication as to where the error is occuring, and because it is occuring before hitting the controller, I dont know how to find out.
For clarrification, I am sure I can handle the error once I find it, my problem is I can find the error, and this is what I am ask help on.
Jan 28, 2013 10:19 PM|LINK
The answer is to have the breakpoint on the BegineRequest, and once the debug pauses, open a Watch window and you can access the form values here.