On my code i'm using log4net to log exception and end of the logging i want to update view with proper message view. on my log service update view (actually my code does redirect) my code look like this
private readonly HttpContextBase _httpContext;
public void RedirectToError()
{
var httpException = _httpContext.Server.GetLastError();
if (httpException != null && (_httpContext.Server.GetLastError() is HttpException))
{
_httpContext.Server.ClearError();
_httpContext.Response.Redirect("/Error", false);
}
}
but i actually wants to update the viewresult only like authorized attribute i able to update the viewresult like this
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
if (filterContext.HttpContext.User.Identity.IsAuthenticated)
{
filterContext.Result = new ViewResult {ViewName = "NoPermissions"};
}
else
{
// let the base implementation redirect the user
base.HandleUnauthorizedRequest(filterContext);
}
}
but nor like filtercontext, how can we update viewresult with httpcontext? if no way to do that with httpcontext how could we achieve this ?
Thanks