views:

91

answers:

0

I am using RequireHttps for my application to redirect t0 https when the user enters http by default. I have followed asp-net-mvc-requirehttps-in-production-only

But after implementing this, i am getting the following error for each request:

System.Web.HttpException: A public action method 'blank.htm' was not found on controller 'MyProject.Web.Controllers.MainController'.
   at System.Web.Mvc.Controller.HandleUnknownAction(String actionName)
   at System.Web.Mvc.Controller.ExecuteCore()
   at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
   at UnitWise.Web.Controllers.BaseController.Execute(RequestContext requestContext)
   at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass8.<BeginProcessRequest>b__4()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
   at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

And also the user gets logged off when the user goes to View/Edit functionality pages, where the url looks like https://www.example.com/User/View/15

What may be problem or any fix i need to do?

Following is the code of my implementation:

public class RemoteRequireHttpsAttribute : System.Web.Mvc.RequireHttpsAttribute
{
   public override void OnAuthorization(System.Web.Mvc.AuthorizationContext filterContext)
   {
      if ((filterContext == null))
      {
          throw new ArgumentNullException("filterContext");
      }

      if ((filterContext.HttpContext != null) && (filterContext.HttpContext.Request.IsLocal || ConfigurationManager.AppSettings["IsSSLEnabled"] == "true"))
      {
           return;
      }
      base.OnAuthorization(filterContext);
   }
}