Same answer as MattMitchell’s but with some modification.
This checks for the default port instead.
Edit: Updated syntax and using
Request.Url.Authority
as suggested
$"{Request.Url.Scheme}{System.Uri.SchemeDelimiter}{Request.Url.Authority}"
More Related Contents:
- A potentially dangerous Request.Form value was detected from the client
- ASP.NET MVC – Set custom IIdentity or IPrincipal
- Can the ViewBag name be the same as the Model property name in a DropDownList?
- Compile Views in ASP.NET MVC
- Returning binary file from controller in ASP.NET Web API
- Injecting content into specific sections from a partial view ASP.NET MVC 3 with Razor View Engine
- How to make custom error pages work in ASP.NET MVC 4
- How to add “active” class to Html.ActionLink in ASP.NET MVC
- Routing for custom ASP.NET MVC 404 Error page
- ASP.NET Bundles how to disable minification
- How and where to call Database.EnsureCreated and Database.Migrate?
- IIS URL Rewriting vs URL Routing
- @Html.DisplayFor – DateFormat (“mm/dd/yyyy”)
- MemoryCache Empty : Returns null after being set
- Context menu to Add Controller/View missing
- The type initializer for ‘System.Data.Entity.Internal.AppConfig’ threw an exception
- How do you avoid XSS vulnerabilities in ASP.Net (MVC)?
- How to allow internal MVC Web Api from external site outside the network
- Display a view from another controller in ASP.NET MVC
- Log4net does not write the log in the log file
- How to return raw string with ApiController?
- asp.net mvc Adding to the AUTHORIZE attribute
- Serving favicon.ico in ASP.NET MVC
- ASP.NET MVC ViewModel Pattern
- Progress bar for long running server calls in ASP.Net MVC [closed]
- ASP.NET MVC Performance
- Data Annotations for validation, at least one required field?
- how to know if the request is ajax in asp.net mvc?
- All requests to ASP.NET Web API return 404 error
- How to decide which is right, WebForms or MVC when doing ASP.NET