How can I replace Request.Url.GetLeftPart (UriPartial.Authority) for the .NET Core View class?

I am trying to migrate several class classes to .NET Core from .NET, and I had a problem with the lack of methods of the "Request" class. The following question may be related to my situation, but I was not sure how to use UriBuilder or any other answer for this purpose. I wanted to ask something more specific and a little different.

What is MVC MVC equivalent to .RequestURI request?

My specific code is as follows:

<form id="contactUs" method="post" action="@Request.Url.GetLeftPart(UriPartial.Authority)@Url.Action("ContactUsFormSubmit")" accept-charset="utf-8"> 

In particular, I need to replace the code part of Request.Url.GetLeftPart(UriPartial.Authority) , since I believe that this is not an affordable package for .NET Core.

Is there a replacement for .NET Core to get the "Power" part in the URL? Can I skip a simple link, etc. Due to my lack of experience in the .NET / .NET Core?

+5
source share
1 answer

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) 
+4
source

All Articles