Related Tags:
Asp.Net It was developed by Microsoft to allow programmers to build dynamic web sites, web applications and web services. It was first released in January 2002 with version 1.0 of the .NET Framework, and is the successor to Microsoft's Active Server Pages (ASP) technology. Learn More, C# C# (pronounced "C-sharp") is an object-oriented programming language from Microsoft that aims to combine the computing power of C++ with the programming ease of Visual Basic. C# is based on C++ and contains features similar to those of Java. Learn More, ASP.NET MVC The ASP.NET MVC framework is a lightweight, highly testable presentation framework that (as with Web Forms-based applications) is integrated with existing ASP.NET features, such as master pages and membership-based authentication. The MVC framework is defined in the System.Web.Mvc assembly. Learn More, HTTP Response Status Code 301 HTTP 301. The HTTP response status code 301 Moved Permanently is used for permanent URL redirection, meaning current links or records using the URL that the response is received for should be updated. The new URL should be provided in the Location field included with the response. Learn More, HTTP Response Status Code 302 The HTTP response status code 302 Found is a common way of performing URL redirection. The HTTP/1.0 specification (RFC 1945) initially defined this code, and gave it the description phrase "Moved Temporarily" rather than "Found". Learn More, HTTP response status codes HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Learn More,

how to redirect dynamically from mvc controller method with status code 301 instead of status code 302?

Description:In my code I am redirecting to new url which is current url appended with the url slugs but when I see in my browser it always gives status code 302 which is for temporary moved redirects but I need to move it permanently with status code 301 is it possible from controller method?

Posted by: | Posted on: Jan 25, 2019

1 answers

Replies

3

for the purpose of permanent redirection with status code 301, method "RedirectPermanent" available in MVC. you can use it similarly as follows.

public ActionResult about()
{
string newUrl="/new-about";
RedirectPermanent("http://www.devargument.com"+ newUrl);
}

Replied by: | Replied on: Jan 29, 2019



Reply
×

Code block Hyperlink bold Quotes block Upload Images

Preview