2016-07-06 11 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

Editを使用依存している場合、私はより洗練されたエラーの説明のためにログをチェックするために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

'私は自分のウェブアプリケーションに問題を引き起こすのですか?'あなたのローカルマシンで動作し、リモートマシンでは動作しない場合でも '遭遇しましたか? 'ということを意味しますか?これはあなたが持つものの1つです以下を確認するには、ターゲットマシンに.netフレームワークがインストールされているか、すべての.dllとサードパーティの.dllがターゲットマシンに展開されていますか? 'Nancy 1.4.2 dll'については、あなたのローカルマシンのReferencesノードでそのDllをクリックすると、' CopyLocal = 'が' True'にセットされていることを確認してください。ターゲット上に同じ仮想パスが設定されていることを確認してくださいあなたはローカルで – MethodMan

+0

@MethodManはい私は遭遇したことを意味し、それを申し訳ありません。私はすべて、dlls、dllのバージョンなどをチェックします。私はlog4netの設定をプロジェクトに追加し、ログには問題がUriオブジェクトを作成していることがわかりました。しかし、ナンシーからのデフォルトのスタックトレースはあまり役に立ちません。 – MNie

+0

URIの問題は何ですか?あなたはその特定のコードやその部分をその問題に関連して表示しません。あなたの質問を編集して同様に投稿できますか? – MethodMan

答えて

0

問題は、私のapp.config内のenvの値が違うことです。したがって、ローカルマシン上ではすべて正常に動作します。しかし、リモートマシン上で

urlFromConfig

anotherUrlFromConfig

http://

接頭辞なしのURLに設定されているので、私はエラーを取得するので、私はそれを追加するとき、すべてが正常に動作を開始します。

関連する問題