0

I have an existing web forms web application. I want to make a slow transition over to mvc3. To make that happen, I'd like to able to from my old user control (System.Web.UI.UserControl) link in my new mvc3 content with Html.Action and Html.Render. Is it possible? Any hackish solution would do.

1 Answer 1

1

Something along these lines should work for an UrlHelper; in your webform:

<% var requestContext = new System.Web.Routing.RequestContext(
       new HttpContextWrapper(HttpContext.Current),
       new System.Web.Routing.RouteData());
   var urlHelper = new System.Web.Mvc.UrlHelper(requestContext); %>

I imagine the same should work for the HtmlHelper; otherwise just use the Url.RouteUrl method:

<a href="<%= urlHelper.RouteUrl(new { controller = "Controller", 
    action = "Action" }) %>">To the MVC app!</a>

For the record, I got it from the following answer: Access HtmlHelpers from WebForm when using ASP.NET MVC

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.