I am looking to serve an image from my root path test.com/some.png but this markdown page may be displayed on [Post]test.com/Item or [Put]test.com/Item/123 So I am looking for a way to get the base URI to form the image link.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the literal text
~/inside a Markdown page gets converted to a virtual path.This literal is registered on start-up from the global
EndpointHostConfig.MarkdownReplaceTokensproperty which is assigned the appHost.Config.WebHostUrl property:Since it’s difficult for an ASP.NET framework to determine the url its hosted at (i.e. without a request) you need to specify the preferred url you wan to use in your config. Here’s an example from the servicestack.net/docs/ – ServiceStack’s markdown Docs project:
Otherwise inside your service you can use
base.Requestorbase.RequestContext.Get<IHttpRequest>()to get information about the incoming Request as well as(HttpRequest)base.Request.OriginalRequestto get the underlying ASP.NET Request object.