我使用MVC提供的标准捆绑来捆绑和缩小我的.css文件。此过程涉及创建虚拟目录(实际上不存在于驱动器上的虚拟目录,而不是IIS使用的虚拟目录概念)。
运行ServiceStack时,从捆绑/缩小的css 的虚拟目录提供的图像中,一切正常(所有页面加载包括图像)除了。
这是我收到的错误
Handler for Request not found:
Request.ApplicationPath: /
Request.CurrentExecutionFilePath: /img/glyphicons-halflings-white.png
Request.FilePath: /img/glyphicons-halflings-white.png
Request.HttpMethod: GET
Request.MapPath('~'): C:\inetpub\TR.net\
Request.Path: /img/glyphicons-halflings-white.png
Request.PathInfo:
Request.ResolvedPathInfo: /img/glyphicons-halflings-white.png
Request.PhysicalPath: C:\inetpub\TR.net\img\glyphicons-halflings-white.png
Request.PhysicalApplicationPath: C:\inetpub\TR.net\
Request.QueryString:
Request.RawUrl: /img/glyphicons-halflings-white.png
Request.Url.AbsoluteUri: https://tr.net/img/glyphicons-halflings-white.png
Request.Url.AbsolutePath: /img/glyphicons-halflings-white.png
Request.Url.Fragment:
Request.Url.Host: tr.net
Request.Url.LocalPath: /img/glyphicons-halflings-white.png
Request.Url.Port: 443
Request.Url.Query:
Request.Url.Scheme: https
Request.Url.Segments: System.String[]
App.IsIntegratedPipeline: True
App.WebHostPhysicalPath: C:\inetpub\TR.net
App.WebHostRootFileNames: [global.asax,hello.cshtml,packages.config,web.config,aspnet_client,assets,bin,bundles,properties,views]
App.DefaultHandler: /Home
App.DebugLastHandlerArgs: GET|/img/glyphicons-halflings-white.png|C:\inetpub\TR.net\img\glyphicons-halflings-white.png
我的web.config如下
<?xml version="1.0" encoding="utf-8"?>
<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>
<pages validateRequest="false"></pages>
<compilation targetFramework="4.5">
<buildProviders>
<add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor" />
</buildProviders>
</compilation>
<httpRuntime targetFramework="4.5" requestValidationMode="2.0" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="ServiceStack.Factory" path="*" verb="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" resourceType="Unspecified" requireAccess="Script" allowPathInfo="true" preCondition="integratedMode" />
</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.Html" />
<add namespace="ServiceStack.Razor" />
<add namespace="ServiceStack.Text" />
<add namespace="ServiceStack.OrmLite" />
</namespaces>
</pages>
</system.web.webPages.razor>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
</assemblyBinding>
</runtime>
我找到了a similar problem here的用户,他的解决方案如下:
未提供虚拟目录中的静态文件,因为应用程序池标识没有读取文件的权限。 虚拟目录中包含的静态文件未被提供,因为ServiceStack处理程序正在为请求提供服务,我没想到会发生这种情况。我不得不删除虚拟目录的服务堆栈处理程序。
但是,我不知道如何执行他所描述的内容。
有人可以帮忙吗?