Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5960835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:52:51+00:00 2026-05-22T18:52:51+00:00

I need to use System.Web.Routing.RequestContext in a view model in order to call HtmlHelper.GenerateLink()

  • 0

I need to use System.Web.Routing.RequestContext in a view model in order to call HtmlHelper.GenerateLink().

In MVC 1.0 it was possible to get the context statically by casting the current IHttpHandler:

 var context = ((MvcHandler) HttpContext.Current.CurrentHandler).RequestContext;

Now the project has been upgraded to MVC 2.0 and this exception is thrown on the cast:

Unable to cast object of type ‘ServerExecuteHttpHandlerWrapper’ to type ‘System.Web.Mvc.MvcHandler’.

I’m not sure if it’s relevant but this is being run in .NET 4.0 on IIS6.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:52:52+00:00Added an answer on May 22, 2026 at 6:52 pm

    I don’t know what you wanna do with the System.Web.Routing.RequestContext? check out:

    var context = new HttpContextWrapper(System.Web.HttpContext.Current);
    var routeData = RouteTable.Routes.GetRouteData(context);
    
    // Use RouteData directly:
    var controller = routeData.Values["controller"];
    
    // Or with via your RequestContext:
    var requestContext = new RequestContext(context, routeData);
    controller = requestContext.RouteData.Values["controller"]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What library I need to reference to use System.Web.Script.Serialization in Class Library ? System.Web
I am using ASP.NET 2.0 on IIS6 therefore I can’t use system.web.routing. I’ve tried
I'm, using MVC to develop a Web application, and I need to use nested
I need to use system-specific functions, e.g. ftello() (defined in stdio.h as per POSIX
I am working on a wpf application. Here I need to use System.Windows.Forms.FolderBrowserDialog in
I use a System.Timers.Timer in my Asp.Net application and I need to use the
I need to use something to coordinate my system with several consumers/producers each running
I need to set up a continuous integration system. We use ClearCase version control
I'm using System.Web.Routing to have some better URL's and have come across a problem.
Iam trying to use System.Web.UI.WebControls.Calender. But when I select any date , It post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.