The code works on our live and development website but when I try to run locally either against my local or development database, I get the error: System.Web.HttpException: 'Response is not available in this context.'
I've tried running a past release that I KNOW works. This only started happening when our code was moved to a new Team Foundation Server. I'm beginning to wonder if this is a setting in Visual Studio's. I used a Watch window and verified the correct information is being passed for the area, action and controller. The URL's that are not null work correctly.
Here is a sample of the code:
/// <summary>
/// Returns the URL for this link
/// </summary>
[NotMapped]
public string trueUrl
{
get
{
if (url != null)
return url;
if (HttpContext.Current != null)
{
var urlhelper = new UrlHelper(HttpContext.Current.Request.RequestContext);
return urlhelper.Action(action, controller, new { area = area });
}
return "ERROR";
}
}
This causes the error: System.Web.HttpException: 'Response is not available in this context.'
I need help on where to look to begin to solve this.