Reputation: 465
So I need the following: When someone navigates to a certain page then it checks if it's the facebook Like crawler. If it's true then it shows the page normally (with the opengraph tags and everything).
If it's false (so the user is just a normal user) it should redirect to a specific external URL.
This is my code so far:
NotebookModel notebookmodel = db.NotebookModels.Find(id);
var isFacebook = Request.UserAgent != null && Request.UserAgent.Contains(Config.FacebookUA);
if (!isFacebook)
{
return Redirect(notebookmodel.Url);
}
return View(notebookmodel);
This works perfectly except for 1 small detail (that does mess up my result): it appends a "+" at the end of my external url once redirected. The url in notebookmodel.Url is right, but once it passed through the Redirect it appends a "+" symbol at the end. Anything I'm doing wrong or can do to fix this?
Upvotes: 0
Views: 1409
Reputation: 1038720
I suspect that you have a whitespace at the end of the notebookmodel.Url
property. Spaces are converted to +
when url encoded. You could Trim it.
Upvotes: 1