views:

33

answers:

2

I'm converting a classic ASP page to ASP.NET MVC 2.

I have a simple form on the page that runs a search. Here's the code:

<form id="searchbox" action="/search.asp">
    <input type="text" name="q" />
    <input type="submit" value="go" name="sa" /> 
</form>

The "/search.asp" page will stay, my new MVC page will just use it. So the form will perform a GET to the url. I'm not sure exactly how to handle a view user control.

Since this isn't Web Forms where you can only have one server form, should I just leave the HTML as is? Or should I hook it up to a controller that will redirect to "/search.asp" with parameters in the query string?

I'm still new to MVC and I couldn't find many resources on view user controls, maybe I'm not searching correctly.

+1  A: 

If it is the legacy application handling the submission simply leave the form as is because the user will be redirected to this page anyways. When the time comes to migrate the search logic to ASP.NET MVC you may start worrying about user controls, controllers, etc...

Darin Dimitrov
A: 

should I just leave the HTML as is?

yes.

You don't want to introduce any extra unnecessary requests. The asp classic page will handle it, no point in fitting MVC in the picture.

One of the benefits of using asp.net MVC vs. web forms is that you are closer to the wire. This gets you to use stuff that's already defined in http / html as is. This is one of such scenarios, while in web forms you could have used that exact html form, it'd have constrained your use of server controls because no nested forms should be used in html ... thus an unneeded extra request is born.

eglasius