title: asp.net mvc3 - Controller method returns View(viewName, string) but weirdness ensues
body: <p>has anyone seen this issue? I'm an ASP.NET MVC newbie. I have an ASP.NET MVC 3 site that uses .aspx and .ascx views. Throughout the site, I use return View() or return View(viewName) in my controller methods, which directs to the appropriate aspx/ascx view. However, in my stock AccountController (modified to use DotNetOpenAuth), I take the same approach, but the MVC framework doesn't seek out aspx or ascx views. Instead, it's searching the path for .cshtml or .vbhtml views (Razor engine I'm assuming). Why woulnd't it just seek out aspx and ascx views like the rest of my site? Controller method follows:</p>
  
  <pre><code>public ActionResult Authenticate()
  {
      var response = openid.GetResponse();
      var statusMessage = "";
      if (response == null)
      {
          Identifier id;
          //make sure your users openid_identifier is valid.
          if (Identifier.TryParse(Request.Form["openid_identifier"], out id))
          {
              try
              {
                  //request openid_identifier
                  return openid.CreateRequest(Request.Form["openid_identifier"])
                     .RedirectingResponse.AsActionResult();
              }
              catch (ProtocolException ex)
              {
                  statusMessage = ex.Message;
                  return View("LogOn", statusMessage);
              }
          }
          else
          {
              statusMessage = "Invalid identifier";
              return View("LogOn", statusMessage);
          }
      }
      else
      {
          //check the response status
          switch (response.Status)
          {
              //success status
              case AuthenticationStatus.Authenticated:
                  Session["FriendlyIdentifier"] = response.FriendlyIdentifierForDisplay;
                  FormsAuthentication.SetAuthCookie(response.ClaimedIdentifier, false);
  
                  //TODO: response.ClaimedIdentifier, to login or create new account 
  
                  return RedirectToAction("Index", "Home");
  
              case AuthenticationStatus.Canceled:
                  statusMessage = "Canceled at provider";
                  return View("LogOn", statusMessage);
  
              case AuthenticationStatus.Failed:
                  statusMessage = response.Exception.Message;
                  return View("LogOn", statusMessage);
          }
      }
      return View("LogOn");
  }
  </code></pre>
  
  <p>Error detail follows:</p>
  
  <blockquote>
    <p>The view 'LogOn' or its master was not
    found or no view engine supports the
    searched locations. The following
    locations were searched:
    ~/Views/Account/Canceled at
    provider.master
    ~/Views/Shared/Canceled at
    provider.master
    ~/Views/Account/LogOn.cshtml
    ~/Views/Account/LogOn.vbhtml
    ~/Views/Shared/LogOn.cshtml
    ~/Views/Shared/LogOn.vbhtml
    ~/Views/Account/Canceled at
    provider.cshtml
    ~/Views/Account/Canceled at
    provider.vbhtml
    ~/Views/Shared/Canceled at
    provider.cshtml
    ~/Views/Shared/Canceled at
    provider.vbhtml</p>
    
    <p>Description: An unhandled exception
    occurred during the execution of the
    current web request. Please review the
    stack trace for more information about
    the error and where it originated in
    the code. </p>
    
    <p>Exception Details:
    System.InvalidOperationException: The
    view 'LogOn' or its master was not
    found or no view engine supports the
    searched locations. The following
    locations were searched:
    ~/Views/Account/Canceled at
    provider.master
    ~/Views/Shared/Canceled at
    provider.master
    ~/Views/Account/LogOn.cshtml
    ~/Views/Account/LogOn.vbhtml
    ~/Views/Shared/LogOn.cshtml
    ~/Views/Shared/LogOn.vbhtml
    ~/Views/Account/Canceled at
    provider.cshtml
    ~/Views/Account/Canceled at
    provider.vbhtml
    ~/Views/Shared/Canceled at
    provider.cshtml
    ~/Views/Shared/Canceled at
    provider.vbhtml</p>
    
    <p>Source Error: </p>
    
    <p>An unhandled exception was generated
    during the execution of the current
    web request. Information regarding the
    origin and location of the exception
    can be identified using the exception
    stack trace below.</p>
    
    <p>Stack Trace: </p>
    
    <p>[InvalidOperationException: The view
    'LogOn' or its master was not found or
    no view engine supports the searched
    locations. The following locations
    were searched:
    ~/Views/Account/Canceled at
    provider.master
    ~/Views/Shared/Canceled at
    provider.master
    ~/Views/Account/LogOn.cshtml
    ~/Views/Account/LogOn.vbhtml
    ~/Views/Shared/LogOn.cshtml
    ~/Views/Shared/LogOn.vbhtml
    ~/Views/Account/Canceled at
    provider.cshtml
    ~/Views/Account/Canceled at
    provider.vbhtml
    ~/Views/Shared/Canceled at
    provider.cshtml
    ~/Views/Shared/Canceled at
    provider.vbhtml]<br>
    System.Web.Mvc.ViewResult.FindView(ControllerContext
    context) +315050<br>
    System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext
    context) +129<br>
    System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext
    controllerContext, ActionResult
    actionResult) +13<br>
    System.Web.Mvc.&lt;>c_<em>DisplayClass1c.b</em>_19()
    +23    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter
    filter, ResultExecutingContext
    preContext, Func<code>1 continuation) +260 
    System.Web.Mvc.&lt;&gt;c__DisplayClass1e.&lt;InvokeActionResultWithFilters&gt;b__1b()
    +19    System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext
    controllerContext, IList</code>1 filters,
    ActionResult actionResult) +177<br>
    System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext
    controllerContext, String actionName)
    +343    System.Web.Mvc.Controller.ExecuteCore()
    +116    System.Web.Mvc.ControllerBase.Execute(RequestContext
    requestContext) +97<br>
    System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext
    requestContext) +10<br>
    System.Web.Mvc.&lt;>c_<em>DisplayClassb.b</em>_5()
    +37    System.Web.Mvc.Async.&lt;>c_<em>DisplayClass1.b</em>_0()
    +21    System.Web.Mvc.Async.&lt;>c_<em>DisplayClass8<code>1.&lt;BeginSynchronous&gt;b__7(IAsyncResult
    _) +12    System.Web.Mvc.Async.WrappedAsyncResult</code>1.End()
    +62    System.Web.Mvc.&lt;>c</em>_DisplayClasse.b_<em>d()
    +50    System.Web.Mvc.SecurityUtil.b</em>_0(Action
    f) +7<br>
    System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action
    action) +22<br>
    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult
    asyncResult) +60<br>
    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult
    result) +9<br>
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    +8841105    System.Web.HttpApplication.ExecuteStep(IExecutionStep
    step, Boolean&amp; completedSynchronously)
    +184</p>
  </blockquote>
  
  <p>Thanks
  Shan</p>