Closed mjharper84 closed 7 years ago
Did you add this tag to your web.config?
<prerender token="YOUR_TOKEN"></prerender>
Ah, I hadn't filled that in! When debugging locally I couldn't get the module to hit any break points using the web.config httpmodule method so I used the PreApplicationStart instead.
I've deployed this (with my token set properly in web.config ) but the site still says You need to install your Prerender token before you can start caching your pages. :(
The only other thing I notice is when stepping through locally 'DoPrerender(_context)' throws an exception: Attempt by method 'Microsoft.ApplicationInsights.Extensibility.DependencyCollector.Tracing.DependencyCollectorEvent Source..ctor()' to access method 'Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.ApplicationNameProvider..ctor()' failed.
Could application insights be affecting things somehow?
My prerender settings are now:
<prerender prerenderServiceUrl="http://service.prerender.io/" crawlerUserAgents="me,you,she,he" token="zXCmLWAspPSInrbPjpHM">
Do I need to modify the crawlerUserAgents at all?
Thanks for your help
Hmm, I'm not sure about that error. Does that only happen when debugging or does that happen every time? Does that make the request fail?
You only need:
<prerender token="YOUR_TOKEN"></prerender>
You should also regenerate your token from our website now that you posted it here. That needs to be kept private so that no one can use your account.
If you are running things locally with a localhost address, you'll have to run a Prerender server locally and set the prerenderServiceUrl to your local instance since our public server wouldn't be able to access your private, localhost address.
Ah it's fine, I changed some of the token around :) I've got ELMAH running on my deployed site now - no exceptions. I have only this defined as settings:
<prerender token="mytoken"></prerender>
Running locally I can see the token get pulled through correctly
_prerenderConfig = ConfigurationManager.GetSection(PRERENDER_SECTION_KEY) as PrerenderConfigSection;
It's a mystery!
Does the request actually go through the Prerender middleware then? Are you able to debug that?
I've attached a remote debugger and it's running through the middleware but this always returns false:
if (!IsInSearchUserAgent(useAgent))
{return false;
}
I set the user agent to googlebot in chrome - I noticed this isn't in the list of crawleruseragents - should it be?
Thanks
No, Googlebot should not be in that list of user agents because Googlebot supports the escaped fragment crawling protocol to prevent you from getting penalized for cloaking.
You need to put this in the <head>
of your pages:
<meta name="fragment" content="!">
And then the crawlers would request your page like:
http://www.example.com/?_escaped_fragment_=
The middleware checks for the _escaped_fragment_
query parameter so that will go through correctly.
I've finally got my token installed! it was a problem with application insights - i removed all the nuget packages and it suddenly started working. If I spoof the user agent as googlebot however I don't get served the static version unless I add ?_escapedfragment= to the end of the URL manually, is this normal or should the spoofing trigger an automatic _escapedfragment= call?
Many thanks!
Great!
Spoofing the googlebot user agent should not do anything. This is the correct behavior to prevent your website getting penalized for cloaking by serving a different page to Google based on user agent.
Google should only get the static HTML page when they see the fragment meta tag on your page and then re-request the page with the ?_escaped_fragment_=
parameter. So it sounds like it's working as expected.
Ah great, finally an SEO friendly SPA :D thanks a lot for you help
Thanks @thoop Help me to answer all questions!
Hi guys,
I'd really like to get this working, I'm not sure what else to try. Here are my steps so far:
I'm using angular in an MVC 5 project, configured to use #! urls. It's hosted as an azure web app/site.
I Downloaded and referenced the project from github (also tried using the nuget package as an alternative ), signed up to preprender.io and got my token. I've tried using the preapplicationstart method and using the web.config httpmodule setting.
I wasn't sure when/where to set my token so I used default value, is this correct?
I'm still getting: "You need to install your Prerender token before you can start caching your pages."
Setting my user agent to googlebot makes no difference to the rendered page. I've looked through the demo MVC project and as far as I can tell I've followed all the steps.
Many thanks for your time