Friday, April 13, 2018

New to MVC need help with custom 301 redirect code

Little background, I'm a .net web forms developer (4 years experience). I'm trying to get the hang of MVC and I'm having some trouble wrapping my head around how to get some custom 301 redirect code working.

I have a database that stores URLs (x) and Values (y) that would correspond to the web.config's rewrites <add key="x" value="y" />

I can load those values just fine, but my problem comes from instances where a controller doesn't exist or there is just a base url (like www.domain.com/to-a-page).

What would be the best way to handle these instance? I've tried writing up a custom controller to check redirects, but in my head I need the code to check if a redirect exists and, if so, go to it before it worries about finding the controller for the original request.

Please feel free to dm me and we can discuss further if I am not making sense.

Thanks in advance.

New to MVC need help with custom 301 redirect code Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team