如果我在本地运行服务器,我可以看到ss-utils.js,但在部署环境(AWS)上,我找不到404。
在我的本地,我在Mac / Mono环境中运行,而AWS服务器在Windows / IIS上。 IIS的设置是否存在访问ss-utils.js的差异?
我在我的代码中设置了HandlerFactoryPath:
Config.HandlerFactoryPath = "api"
所以理论上它应该在我访问/api/js/ss-utils.js时有效但是,我仍然得到404
这是调试请求信息
{
"Usage": "append '?debug=requestinfo' to any querystring",
"Host": "WebServer20_v4.050_pM",
"Date": "2016-01-21T00:42:33.4022859Z",
"ServiceName": "pM",
"HandlerFactoryPath": "api",
"UserHostAddress": "10.0.X.XXX",
"HttpMethod": "GET",
"PathInfo": "/js/ss-utils.js",
"ResolvedPathInfo": "/js/ss-utils.js",
"StripApplicationVirtualPath": false,
"GetLeftPath": "http://uat.zzzz.com",
"Path": "/api/js/ss-utils.js",
"GetPathUrl": "http://uat.zzzz.com/api/js/ss-utils.js",
"AbsoluteUri": "http://uat.zzzz.com/api/js/ss-utils.js?debug=requestinfo",
"WebHostUrl": null,
"ApplicationBaseUrl": "https://uat.zzzz.com/api",
"ResolveAbsoluteUrl": "https://uat.zzzz.com/api/resolve",
"ApplicationPath": "/",
"ApplicationVirtualPath": "/",
"VirtualAbsolutePathRoot": "/",
"VirtualAppRelativePathRoot": "~/",
"CurrentDirectory": "C:\\Windows\\SysWOW64\\inetsrv",
"HandlerFactoryArgs": "GET|/api|C:\\Octopus\\Applications\\UAT\\pM.ApiHost\\1.20.6016\\api",
"RawUrl": "/api/js/ss-utils.js?debug=requestinfo",
"Url": null,
"ContentType": "",
"Status": 0,
"ContentLength": 0,
"Headers": {
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Pragma": "no-cache",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Encoding": "gzip, deflate, sdch",
"Accept-Language": "en-US,en;q=0.8",
"Cookie": "SS_MID=960a1c12-c454-4985-8db7-8341706aa589i3XXXXX; ss_cid=7cd0127a-0cce-44cd-b248-b8b6a8XXXXXX; __utma=30576126.2094331120.1418258412.1430269692.1430807371.78; __utmc=30576126; _ga=GA1.2.2094331120.1418258412; ss-id=XXXXXX; ss-pid=XXXXXX; X-UAId=1462;,
"Host": "uat.zzzz.com",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36",
"Upgrade-Insecure-Requests": "1",
"X-Proxied-By": "ip-10-0-1-11",
"X-Forwarded-For": "203.xxx.xxx.xxx, 10.0.1.11",
"X-Forwarded-Port": "80",
"X-Forwarded-Proto": "http"
},
"QueryString": {
"debug": "requestinfo"
},
"FormData": {},
"AcceptTypes": [
"text/html",
"application/xhtml+xml",
"application/xml;q=0.9",
"image/webp",
"*/*;q=0.8"
],
"OperationName": "/api",
"ResponseContentType": "text/html",
"ErrorCode": null,
"ErrorMessage": null,
"LogonUserInfo": {
"Name": "NT AUTHORITY\\IUSR",
"AuthenticationType": "",
"IsAuthenticated": "False",
"IsAnonymous": "False",
"IsGuest": "False",
"IsSystem": "False",
"Groups": "S-1-1-0, S-1-5-32-545, S-1-2-1, S-1-5-11, S-1-5-15, S-1-2-0",
"User": "S-1-5-17",
"User.AccountDomainSid": "null",
"User.IsAccountSid": "False"
},
"DebugString": "System.Web.HttpRequest|System.Web.HttpResponse",
"OperationNames": null,
"AllOperationNames": null,
"RequestResponseMap": null,
"PluginsLoaded": [
"HtmlFormat",
"CsvFormat",
"MarkdownFormat",
"PredefinedRoutesFeature",
"MetadataFeature",
"NativeTypesFeature",
"SessionFeature",
"AuthFeature",
"RazorFormat",
"ValidationFeature",
"ServerEventsFeature"
],
"StartUpErrors": [],
"LastRequestInfo": {
"HandlerType": "RestHandler",
"OperationName": "Ping",
"PathInfo": "/test/ping/dnshealthcheck"
},
"Stats": {
"RawHttpHandlers": "3",
"PreRequestFilters": "0",
"RequestBinders": "0",
"GlobalRequestFilters": "2",
"GlobalResponseFilters": "3",
"CatchAllHandlers": "4",
"Plugins": "11",
"ViewEngines": "2",
"RequestTypes": "553",
"ResponseTypes": "231",
"ServiceTypes": "480",
"RestPaths": "632",
"ContentTypes": "5",
"EnableFeatures": "All",
"VirtualPathProvider": "[FileSystemVirtualPathProvider: C:\\Octopus\\Applications\\UAT\\pM.ApiHost\\1.20.6016], [ResourceVirtualPathProvider: pM.ApiHost], [ResourceVirtualPathProvider: ServiceStack]"
},
"VirtualPathProviderFiles": []
}
请求标题:
GET /api/js/ss-utils.js HTTP/1.1
Host: uat.zzzz.com
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
Cookie: SS_MID=960a1c12-c454-4985-8db7-8341706aa589i300000; ss_cid=7cd0127a-0cce-44cd-b248-b8b6a8000000; __utma=30576126.2094331120.1418258412.1430269692.1430807371.78; __utmc=30576126; ss-id=xxxx; ss-pid=xxxx; X-UAId=1462; __ngDebug=true; _ga=GA1.2.2094331120.1418258412;
回复标题:
HTTP/1.1 404 Not Found
Cache-Control: private
Content-Type: text/plain; charset=utf-8
Date: Thu, 21 Jan 2016 23:51:45 GMT
Server: nginx
Vary: Accept
X-AspNet-Version: 4.0.30319
Content-Length: 3
Connection: keep-alive
答案 0 :(得分:2)
ss-utils.js是 ServiceStack.dll 中的嵌入式资源,该资源应位于路径/js/ss-utils.js
,例如:
上述网站的所有链接都托管在AWS / IIS / Windows
上
Config.EmbeddedResourceSources
或Config.EmbeddedResourceBaseTypes
中注册的.dll中包含的所有Embedded Resources都由ServiceStack Virtual File System自动提供,默认情况下包含 ServiceStack.dll ,其中包含/js/ss-utils.js
,因此默认情况下会自动显示。
如果未在/js/ss-utils.js
投放,则可能存在问题,请?debug=requestinfo
[Route("/files/{Path*}")]
public class GetFile
{
public string Path { get; set; }
}
public class FileServices : Service
{
public object Any(GetFile request)
{
var file = VirtualFileSources.GetFile(request.Path);
if (file == null)
throw HttpError.NotFound("File '{0}' does not exist".Fmt(request.Path));
return new HttpResult(file) {
ContentType = MimeTypes.GetMimeType(file.Extension)
};
}
}
检查可能导致无效AppHost的任何StartUp错误配置。
您的调试信息看起来很好,所以我希望请求按预期返回文件。下一步是查看是否可以从Debug RequestInfo解析文件。要测试这个,您可以添加此服务:
/api/files/js/ss-utils.js
这将让您调用以下网址:
/js/ss-utils.js
返回从虚拟文件系统解析的文件。如果您添加了任何静态文件,例如{{1}},请按Virtual File System重命名或删除它。