Question

I've been in the process of attempting to deploy an ASP.NET 4.0 (webform) project on a server that is running an ASP.NET MVC 1.0 application in it's web-root. I was slowly making progress, but hit a wall, so I decided to recompile the MVC app against version 2.0 of the MVC framework and 4.0 of the .NET framework. I used a few tools to do so.

The project appeared to successfully convert, but now it fails to compile. Specifically, it appears that there is a problem with System.Web.HttpContextBase.

For example, if I have the following code:

context.HttpContext.Response.Clear();

I get the following error:

'System.Web.HttpContextBase' does not contain a definition for 'Response' and no extension method 'Response' accepting a first argument of type 'System.Web.HttpContextBase' could be found (are you missing a using directive or an assembly reference?)

I've checked the object explorer just to make sure: HttpContextBase does have a property called Response. This thing is driving me crazy.

I have another big problem, which I believe to be related. Anytime the Request object is queried:

Request["old"];

It says:

Cannot apply indexing with [] to an expression of type 'System.Web.HttpRequestBase'

As far as I can tell, there isn't any reason for this either.

I'm at my wits end. I've checked the breaking changes document for MVC 2.0 but didn't see anything related to this. The references all look good to me; the version numbers all check out.

Further note on the server issue: I do not have any access to the deployment web server except ftp. I cannot go in and mess around with the server configuration. That's why this may sound a little odd to you.

Was it helpful?

Solution

I'm glad that worked for you, here it is again as an answer for everyone else

It's possible your IDE and Runtime are disagreeing over which library version to use. Try creating a new project and moving your source over to it and compiling again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top