0
以下はasp.netフレームワークのコードです。asp.netコアのRequestUri
protected HttpResponseMessage Created<T>(T apiResponse, ObjectId id) where T: ILinking
{
//var builder = new UriBuilder();
Uri uri = new Uri(this.RequestUri(), id.ToString());
apiResponse.get_Links().Add(new ApiLink(uri, "created", HttpMethod.Get));
HttpResponseMessage message = base.Request.CreateResponse<T>(HttpStatusCode.Created, apiResponse);
message.Headers.Add("Location", uri.ToString());
return message;
}
私はasp.netコアで移行したいと考えています。私はそれを多くgoogleしかし、任意の解決策を見つけることができません。どうすればasp.netコアのthis.RequestUri()を宣言できますか?
ありがとうございます。
私は.NETの世界では比較的新しいですが、6ヶ月前にASP.NET Core 1.0で私の冒険を始めました(以前のバージョンのリファレンスはありません)。ユーザーの実際のURIを取得しますか? この場合、次のコードが役に立ちます: 'string host = context.Request.Host.ToString();' 'string path = context.Request.Path.ToString();' – LeCintas
元の 'RequestUri () 'のように見えますか?これは標準的な方法ではありません。それでも、現在のリクエストURIだけを返すと仮定すると、 'this.Request.RequestUri'を使うことができます。 – haim770
" this "とは何ですか? – MindingData