我在ServiceStack.Razor 中呈现了一个非常基本的 html 表单ViewPage
:
<form action="@Href("~/subfolder/someservice")" method="POST">
<input...>
...
</form>
从虚拟应用程序目录中的本地 IIS 运行时,它工作正常。但是,一旦部署到 AppHarbor,我就会收到此错误:
此处不允许使用相对虚拟路径“http:/myssrazorapp.apphb.com/subfolder/someservice”。
[ArgumentException: The relative virtual path 'http:/myssrazorapp.apphb.com/subfolder/someservice' is not allowed here.]
System.Web.VirtualPath.Create(String virtualPath, VirtualPathOptions options) +877
System.Web.VirtualPath.CreateNonRelative(String virtualPath) +9
System.Web.VirtualPathUtility.ToAbsolute(String virtualPath) +8
ServiceStack.Html.UrlHelper.Content(String url) +6
ServiceStack.Razor.ViewPageBase`1.Href(String url) +10
CompiledRazorTemplates.Dynamic.dbbfcbafad.Execute() +291
ServiceStack.Razor.Templating.TemplateService.ExecuteTemplate(T model, String name, String defaultTemplatePath, IHttpRequest httpReq, IHttpResponse httpRes) +149
ServiceStack.Razor.RazorFormat.ExecuteTemplate(T model, String name, String templatePath, IHttpRequest httpReq, IHttpResponse httpRes) +80
ServiceStack.Razor.RazorFormat.ProcessRazorPage(IHttpRequest httpReq, ViewPageRef razorPage, Object dto, IHttpResponse httpRes) +50
ServiceStack.Razor.RazorHandler.ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, String operationName) +366
ServiceStack.WebHost.Endpoints.Support.EndpointHandlerBase.ProcessRequest(HttpContext context) +164
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +859
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +131
我查看了源代码(ViewPageBase.Href和UrlHelper.Content),他们所做的只是将原始字符串传递给VirtualPathUtility.ToAbsolute
. 除了 AppHarbor 环境以某种方式影响 VirtualPathUtility 的功能之外,我无法解释是什么原因造成的。
错误的奇怪之处在于http:/
前缀缺少一个正斜杠。不确定这是否会给任何人带来任何提示?