2016-07-06 159 views
0

我遇到了我的web應用程序出現的問題。 當我在本地運行它時,一切都很好,我得到一個rss提要。但是當我將我的應用程序部署到遠程機器時。我得到這樣一個錯誤:嘗試在南希返回rss訂閱源時出現異常

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提要的一部分。這

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和他們另一個行動在本地機器上也可以在遠程工作。我不知道爲什麼這個返回不同於json/html /純文本的特定代碼不能在遠程機器上運行。

如果這取決於我使用.NET 4.5和南希1.4.2

編輯我添加一個log4net的檢查更復雜的錯誤描述日誌。

在日誌我有以下錯誤:

Invalid URI: The format of the URI could not be determined.

以及使用一個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

'我鼓勵我的網絡應用程序出現問題.'你的意思是你遇到過嗎?'如果它在你的本地機器上工作,並且不能在遠程機器上工作..這是你將會有的東西之一檢查以查看以下內容,是目標計算機上安裝的.net框架,是否將所有.dll和第三方.dll部署到目標計算機..?對於'Nancy 1.4.2 dll',確保當你在本地機器上的References節點上點擊那個Dll時,你將'CopyLocal ='設置爲'True',確保你在目標上有相同的虛擬路徑設置你在本地 – MethodMan

+0

@MethodMan是的我的意思是遇到,對不起。我檢查了一切,dll,dll的版本等。我將一個log4net配置添加到項目中,並在日誌中發現問題在於創建Uri對象......所以我現在正在調查它。但南希的默認堆棧跟蹤並不是那麼有用。 – MNie

+0

URI的問題是什麼?你不會顯示那個問題的特定代碼和/或部分..你可以編輯你的問題併發布,以及..? – MethodMan

回答

0

問題是我有我的app.config中的任何env不同的值。所以在本地機器上一切正常。但在遠程機器上我得到的錯誤,因爲

urlFromConfig

anotherUrlFromConfig

被設置爲一個網址,沒有

http://

前綴,所以當我加入這一切開始正常工作。