aspnetcore-angular-universal icon indicating copy to clipboard operation
aspnetcore-angular-universal copied to clipboard

Redirect 301 for seo

Open borgotecnologia opened this issue 9 years ago • 3 comments

Is it possible identify if the google links are wrong and make a redirect 301 or 302 on the server? Previously without dotnet javascript service I did in the node like :

constructor( @Inject('response') private _response: any, @Inject('isNode') private _isNode: boolean ) {}

public redir301(location: string): void { if (this._isNode) { this._response.redirect(301, location); } }

borgotecnologia avatar Apr 06 '17 22:04 borgotecnologia

You'd have to have some kind of a Service triggered when a 404 comes, and in your main.server file, when you get your Html result etc, you'd probably want to return something else instead... maybe a StatusCode / etc. Then in your HomeController look to see if that statusCode is there, and do a server Redirection (instead of rendering the angular app client-side 404).

Hope that helps! Let me know if you make any progress on that, we could put in an example of it for others to see if they need it.

MarkPieszak avatar Apr 07 '17 18:04 MarkPieszak

I used Meta servise to set meta tag with http response code.

Then I parsed it from asp and set in in response.

hheexx avatar Apr 07 '17 20:04 hheexx

Now that we have #179 that has the REQUEST etc you should be able to handle this that way, or as Boris pointed out, and just set something or a specific response you can look for when you get the Result back in .NET from prerendering, and handle your Redirect there (instead of returning the View).

Hope that helps!

MarkPieszak avatar Apr 14 '17 14:04 MarkPieszak