2014-02-18 22 views
0

所以,我試圖找出這個無濟於事。Servicestack Razor'模型'在這方面不存在

我創建了一個新的空ASP.NET Web應用程序在2013年VS

新增ServiceStack framwork和剃刀引擎爭奪的NuGet。

添加了一個簡單的/Services/LogonSvc.cs服務,以及帶有[Route(「/ Logon」)]的Logons DTO類。

添加了一個簡單/Views/Logon/Logons.cshtml

web.config文件應該是正確的,因爲通過的NuGet模板創建的,對不對?

但是VS仍然在說「名稱模型」在當前上下文中不存在。「 「佈局」也一樣。

將web.config文件複製到Views文件夾中。不用找了。

<?xml version="1.0" encoding="utf-8"?> 
<!-- 
    For more information on how to configure your ASP.NET application, please visit 
    http://go.microsoft.com/fwlink/?LinkId=169433 
    --> 
<configuration> 
    <configSections> 
     <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> 
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false"  /> 
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /> 
     </sectionGroup> 
    </configSections> 
    <system.web> 
     <compilation debug="true" targetFramework="4.5"> 
      <assemblies> 
       <add assembly="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
      </assemblies> 
      <buildProviders> 
       <add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor" /> 
      </buildProviders> 
     </compilation> 
     <httpRuntime targetFramework="4.5" /> 
     <httpHandlers> 
      <add path="*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" /> 
     </httpHandlers> 
    </system.web> 
    <system.webServer> 
     <modules runAllManagedModulesForAllRequests="true" /> 
     <validation validateIntegratedModeConfiguration="false" /> 
     <handlers> 
      <add path="*" name="ServiceStack.Factory" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" /> 
     </handlers> 
    </system.webServer> 
    <appSettings> 
     <add key="webPages:Enabled" value="false" /> 
    </appSettings> 
    <system.web.webPages.razor> 
     <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 
     <pages pageBaseType="ServiceStack.Razor.ViewPage"> 
      <namespaces> 
       <add namespace="ServiceStack" /> 
       <add namespace="ServiceStack.Html" /> 
       <add namespace="ServiceStack.Razor" /> 
       <add namespace="ServiceStack.Text" /> 
       <add namespace="ServiceStack.OrmLite" /> 
       <add namespace="Telestion.Web" /> 
       <add namespace="Telestion.Web.Dto"/> 
      </namespaces> 
     </pages> 
    </system.web.webPages.razor> 
</configuration> 

Logons.cshtml,與在 「模型」 和 「佈局」 波浪線:

@model Telestion.Web.Dto.LogonResponse 
@{ 
    Layout = null; 
} 

<!DOCTYPE html> 
<html> 
<head> 
    <meta name="viewport" content="width=device-width" /> 
    <title></title> 
</head> 
<body> 
    <div>  
    </div> 
</body> 
</html> 

任何想法?

回答

3

我不確定,但這可能會解決您的問題。

在你.cshtml,刪除此行:
@inherits ServiceStack.Razor.ViewPage<Telestion.Web.Dto.LogonResponse>


@model Telestion.Web.Dto.LogonResponse
然後在文件開頭添加這
相關問題