2011-02-23 22 views
10

bu sorunu gören oldu mu? Ben bir ASP.NET MVC acemi. .aspx ve .ascx görünümlerini kullanan bir ASP.NET MVC 3 sitem var. Site genelinde denetleyici yöntemlerimde View() veya return View (viewName) döndürme özelliğini kullanıyorum, bu da uygun aspx/ascx görünümüne yönlendiriyor. Ancak, Hisse Senedi (DotNetOpenAuth kullanmak için değiştirildi) benim stokta, aynı yaklaşımı almak, ancak MVC framework aspx veya ascx görünümleri arar. Bunun yerine, .cshtml veya .vbhtml görünümleri için yol arıyor (Jilet motoru varsayıyorum). Neden sadece benim sitemin geri kalanı gibi aspx ve ascx görünümleri arıyoruz? Denetleyici yöntem aşağıdaki gibidir:asp.net mvc3 - Denetleyici yöntemi döndürür Görünüm (viewName, string) ancak gariplik

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"); 
} 

Hata detay aşağıdaki gibidir:

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

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.

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

Source Error:

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.

Stack Trace:

[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]
System.Web.Mvc.ViewResult.FindView(ControllerContext context) +315050
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +129
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
System.Web.Mvc.<>c_DisplayClass1c.b_19() +23 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func 1 continuation) +260 System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList 1 filters, ActionResult actionResult) +177
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343 System.Web.Mvc.Controller.ExecuteCore() +116 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c_DisplayClassb.b_5() +37 System.Web.Mvc.Async.<>c_DisplayClass1.b_0() +21 System.Web.Mvc.Async.<>c_DisplayClass8 1.<BeginSynchronous>b__7(IAsyncResult _) +12 System.Web.Mvc.Async.WrappedAsyncResult 1.End() +62 System.Web.Mvc.<>c_DisplayClasse.b_d() +50 System.Web.Mvc.SecurityUtil.b_0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841105 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

Teşekkür Shan

cevap

25

anahtarı istisna ilk satırında geçerli:

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 

Eğer geçerseniz View() için iki dizge, birincisi görünüm adı ve ikincisi t'nin adıdır. Kullanmak için görünümü veya şablonu usta. Eğer görüntülemek için model olarak StatusMessage geçmek istiyorsanız bu size bir model geçmesi nerede geçersiz kılınan View() method arayarak zorlar hangi nesne yayın yapabilirsiniz: Sen görünüşte "İptal sağlayıcısı" mesajı alıyorsanız

return View("LogOn", (object)statusMessage); 

ve Bunu kullanmak için ana sayfa adı olarak geçiyor. "Logon.aspx" görünümü bir ana sayfa kullandıysa ve örneğin Paylaşılan görünüm klasörünüzde "provider.master adresinden iptal edildi" ana sayfanız varsa, "LogOn.aspx" görünümü yüklenir ve " Varsayılan olarak farklı bir ana sayfayı kullanacak şekilde ayarlanmış olsa bile provider.master "ana sayfasından iptal edildi:

string statusMessage = "Canceled at provider"; 
return View("LogOn", statusMessage); 
+2

Teşekkürler Jason, bu akşamı deneyeceğim. ASP.NET MVC mesajıyla ilgili "Görüş 'LogOn' veya yöneticisi bulunamadı, ya da herhangi bir görünüm motoru aranan yerleri desteklemiyor." Ben tamamen ASP.NET MVC 3 "sağlayıcıda iptal edildi" için bakıyordu ve bir LogOn.cshtml için arama _was_ daha fazla sıkışmış oldu (mesajda arama yollarına bakın, bulabilirsiniz ~/Görünümler LogOn.aspx veya LogOn.ascx için değil, örneğin /Account/LogOn.cshtml). –

+0

Mantıktan emin değilim, ama sanırım ana sayfayı bulamadığında durması. Ana sayfayı buraya koyarsanız, LogOn.aspx dosyasını bulabilirsiniz ve belirtilen master'i kullanın. –

+1

Mükemmel, tekrar teşekkürler Jason –