我的网络应用遇到了问题。 当我在本地运行它时,一切都很好,我得到一个rss feed。但是当我将我的应用程序部署到远程计算机时。我收到这样的错误:
Nancy.ViewEngines.ViewNotFoundException: Unable to locate view 'UriFormatException'
Currently available view engine extensions: sshtml,html,htm,cshtml,vbhtml
Locations inspected: views/Renderer/UriFormatException-pl,views/Renderer/UriFormatException,Renderer/UriFormatException-pl,Renderer/UriFormatException,views/UriFormatException-pl,views/UriFormatException,UriFormatException-pl,UriFormatException
Root path: C:\WebAppPath
If you were expecting raw data back, make sure you set the 'Accept'-header of the request to correct format, for example 'application/json'
at Nancy.ViewEngines.DefaultViewFactory.GetRenderedView(String viewName, Object model, ViewLocationContext viewLocationContext)
at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at CallSite.Target(Closure , CallSite , DefaultViewFactory , Object , Object , ViewLocationContext )
at Nancy.ViewEngines.DefaultViewFactory.RenderView(String viewName, Object model, ViewLocationContext viewLocationContext)
at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at CallSite.Target(Closure , CallSite , IViewFactory , String , Object , ViewLocationContext )
at Nancy.Responses.Negotiation.ViewProcessor.Process(MediaRange requestedMediaRange, Object model, NancyContext context)
at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at CallSite.Target(Closure , CallSite , IResponseProcessor , String , Object , NancyContext )
at Nancy.Responses.Negotiation.DefaultResponseNegotiator.NegotiateResponse(IEnumerable`1 compatibleHeaders, NegotiationContext negotiationContext, NancyContext context)
at Nancy.Responses.Negotiation.DefaultResponseNegotiator.CreateResponse(IList`1 compatibleHeaders, NegotiationContext negotiationContext, NancyContext context)
at Nancy.Responses.Negotiation.DefaultResponseNegotiator.NegotiateResponse(Object routeResult, NancyContext context)
at Nancy.NancyEngine.InvokeOnErrorHook(NancyContext context, ErrorPipeline pipeline, Exception ex)
这是我的代码的一部分,负责生成rss feed ..
Get["GetFeed"] = _ =>
{
var feed = _feedProvider.GetFeed();
var sw = new StringWriter();
using (var xmlWriter = new XmlTextWriter(sw))
{
xmlWriter.WriteProcessingInstruction("xml-stylesheet", "type='text/xsl' href='format.xsl'");
xmlWriter.Formatting = Formatting.Indented;
new Rss20FeedFormatter(feed).WriteTo(xmlWriter);
}
var res = (Response) sw.ToString();
res.ContentType = "text/xml";
return res;
}
此外,我还有另一个返回简单json的操作,它们可以在localmachine和remote上运行。我不知道为什么这个返回与json / html / plain文本不同的特殊代码不能在远程机器上运行。
如果这取决于我使用.net 4.5和Nancy 1.4.2
在日志中,我遇到以下错误:
无效的URI:无法确定URI的格式。
使用Uri的代码中只有一部分是_feedProvider.GetFeed()函数。
public SyndicationFeed Get()
{
var alternateLink = new Uri(urlFromConfig);
var items = GetItems();
return new SyndicationFeed("Title", "", alternateLink, items)
{
Copyright = new TextSyndicationContent(""),
Language = "pl-PL",
ImageUrl = new Uri(anotherUrlFromConfig)
};
}
答案 0 :(得分:0)
问题是我的app.config中的任何env都有不同的值。所以在本地机器上一切正常。但是在远程计算机上我得到错误,因为
urlFromConfig
anotherUrlFromConfig
设置为没有
的网址的http://
前缀,所以当我添加它时,一切都开始正常工作。