I am trying to migrate few View classes into .NET Core from .NET and I am having an issue with the lack of "Request" class methods. The following question might be related to my situation but I wasn't sure how to use UriBuilder or any of the other answer for this purpose. I wanted to ask something more specific and a little different.
What is the ASP.NET Core MVC equivalent to Request.RequestURI?
My specific code is as follows:
<form id="contactUs" method="post" action="@Request.Url.GetLeftPart(UriPartial.Authority)@Url.Action("ContactUsFormSubmit")" accept-charset="utf-8">
Specifically I need to replace the Request.Url.GetLeftPart(UriPartial.Authority)
part of the code as I believe that it is not an available package for .NET Core.
Is there a replacement for .NET Core to get the "Authority" part of the Url? Could I be missing a simple reference etc due to my lack of experience in .NET/.NET Core?
You can use the GetComponents method of the Uri class. This should work for your case:
Request.Url.GetComponents(UriComponents.Scheme | UriComponents.StrongAuthority, UriFormat.Unescaped)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With