Make indexable an ajax based webpage - html

I want to make indexable my ajax based website.
I have read this doc: https://developers.google.com/webmasters/ajax-crawling/docs/getting-started But I don't understand it at all.
I think I need to do it:
Write this tag in a webpage, for example: www.myweb.com/mypage
<meta name="fragment" content="!">
I'm using UrlRewriteFilter for my Tomcat Server (http://tuckey.org/urlrewrite/), so I think I could redirect the urls with the substring: "?_escaped_fragment_=" to a html snapshot (which I can build manually, writing my custom meta-description, title and content???)
<rule>
<from>^/mypage\?_escaped_fragment_=</from>
<to type="forward">/snapshots/mypage.html</to>
</rule>
Write the URLs (without the escaped fragment) into the sitemap.xml
...
<url>
<loc>www.myweb.com/mypage</loc>
...
</url>
...
Is it right? I need to do something more?

Ok, it is right, but the UrlRewriteFilter syntax is a bit different:
<rule>
<condition name="_escaped_fragment_" type="parameter" operator="equal"></condition>
<from>^/mypage/</from>
<to last="true">/snapshots/mypage.html</to>
</rule>

Related

Is it possible to display an xml code on a page in ReactJS?

Say I have this xml code and I want to display it on my page:
<?xml version=\"1.0\" encoding=\"UTF-8\" ?> <rss version=\"2.0\">
<channel>
<title>W3Schools Home Page</title>
<link>https://www.w3schools.com</link>
<description>Free web building tutorials</description>
<item>
<title>RSS
Tutorial</title>
<link>https://www.w3schools.com/xml/xml_rss.asp</link>
<description>New RSS tutorial on W3Schools</description> </item> </channel> </rss>
I tried doing this, but the output is not what I want:
<div dangerouslySetInnerHTML={{ __html: this.state.body }} />
The output is like this:
https://www.w3schools.com Free web building tutorials https://www.w3schools.com/xml/xml_rss.asp New RSS tutorial on W3Schools
Which is not what I want. I want it to display the rss feed on my page without redirecting me, how can I do that? (Btw, the body is reading perfectly fine, so the problem is not from the body)
If you want to show the XML source code, then just output it as you would any other text:
<div>
{ this.state.body }
</div>
If you want to do sensible formatting, then you'll need to actually parse the XML and extract the data you care about from it. (There are JavaScript RSS parsers out there, you might want to look on NPM for a library you can use to do the heavy lifting for you).

IIS7: Manipulate headers for html files in Classic mode

I'm using an angular directive to pull an html file from my IIS7 classic mode server (classic required due to SSO). To satisfy CORS I need read the ORGIN from the request and add a header to the response of the html file. That bit doesn't really matter. My problem is hooking in my code to actually do this for a static HTML file.
So with classic mode my handlers/module are defined in system.web, not system.webSever. Therefore I can't use the runAllManagedModulesForAllRequests="true" flag which isn't part of the schema for system.web.
In system.web I have:
<httpHandlers>
<!--<add path="*.html" verb="GET,HEAD" type="System.Web.StaticFileHandler" />-->
<add path="*.html" verb="GET,HEAD" type="My.Namespace.CrossOriginHandler, My.DLL.Name" />
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler" />
</httpHandlers>
<httpModules>
<add name="CrossOriginModule" type="My.Namespace.CrossOriginModule, My.Dll.name" />
</httpModules>
This executes fine for a MVC pages or webapi calls. It does not execute for my static HTML file.
I'm starting to fear I'm going to need to write a custom ISAPI filter. Is there any other way to hook in my code? A configuration I'm missing or hook inbetween ISAPI filter and HttpModule?
There are a couple of options you have and definitely you should not need to write an ISAPI for that.
One option if you can set it for everyone blindly is to just use the httpProtocol section to add the header:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
however, a much better option is to use URL Rewrite to set the headers and still have all the control to check for origins, and rewrite them appropriately.
I wrote a quick article on how to do that here:
http://www.carlosag.net/articles/enable-cors-access-control-allow-origin.cshtml
At a high level it means adding a URL Rewrite inbound rule to capture the Origin header and set it in a server variable. Then you can use that server variable later in an outbound rule to set it in a header. Optionally I used a Rewrite Map to condition the origins that you wanted to allow that.
<outboundRules>
<rule name="Set-Access-Control-Allow-Origin for known origins">
<match serverVariable="RESPONSE_Access-Control-Allow-Origin" pattern=".+" negate="true" />
<conditions>
<add input="{AllowedOrigins:{CAPTURED_ORIGIN}}" pattern=".+" />
</conditions>
<action type="Rewrite" value="{C:0}" />
</rule>
</outboundRules>
see full explanation here: http://www.carlosag.net/articles/enable-cors-access-control-allow-origin.cshtml

SSRS ReportViewer URL in CRM Ribbon

I've added a button to print a SSRS report to one of my CRM ribbons. The only issue is that every time it calls the URL the path is removed from the url parameters. For example the URL I have in the XML is:
<CommandDefinition Id="Company.Form.quote.MainTab.Actions.PrintQuote.Command">
<EnableRules />
<DisplayRules />
<Actions>
<Url Address="http://<Server>/ReportServer/Pages/ReportViewer.aspx?/Test/ReportName">
<CrmParameter Name="QuoteId" Value="FirstPrimaryItemId" />
<StringParameter Value="Render" Name="rs:Command" />
<StringParameter Name="rs:Format" Value="PDF" />
</Url>
</Actions>
</CommandDefinition>
And the URL it navigates to is:
http://<server>/ReportServer?QuoteId=%7bE6D8DC8B-6381-E411-80BC-00155D18D500%7d&rs%3aCommand=Render&rs%3aFormat=PDF
It seems that I need a name for the ItemPath, but ReportServer doesn't accept one I know of, is there a way around this?
Any help is appreciated.
Found a workaround,
I did the same thing, just instead of putting the URL in the CommandDefinition I used javascript to redirect.

Razor RenderPage my.js without HttpException

Suppose I want to render javascript from an external file inline into my layout file for performance reasons.
If I use the following Razor code
<script>
#RenderPage("~/Content/my.js")
</script>
results in
Server Error in '/' Application.
The following file could not be
rendered because its extension ".js" might not be supported:
"~/Content/my.js".
If I merely rename my javascript file to my.js.cshtml
<script>
#RenderPage("~/Content/my.js.cshtml")
</script>
The peasants rejoice.
The question:
Is there any simple way for me to prevent RenderPage from nagging such that I can tell it that the .js extension is fine?
With some feedback from #choudeshell one potential solution is:
<compilation debug="true" targetFramework="4.5">
<buildProviders>
<remove extension=".js"/>
<add extension=".js" type="System.Web.WebPages.Razor.RazorBuildProvider,
System.Web.WebPages.Razor"/>
</buildProviders>
</compilation>
What type of side effects would there be from removing whatever the default is for .js, any?

WSO2 ESB - HTML Response

I built a GET REST webservice (Rest API) which has to return text/html.
Inside the sequence I have a Mediator where I invoke a webpage (like http://www.mypage.com or something), and get its contents into a String variable.
After that I need to do some string replacements in the content and send it back as text/html to the client.
The problem is that when I got it back in my page the esb has replaced all <html> and other tags to <html> tags. So the web browser does not render a html page, but just writes the tags in the page itself.
The main idea is that it works like a proxy to a servlet, where I call a servlet, get the response, do some string replacements inside de html and javascript that I got, and send it to client.
Here is the sequence xml:
<resource methods="GET" uri-template="/view">
<inSequence>
<log level="full"/>
<header name="To" action="remove"/>
<property name="URL" value="http://www.mypage.com"/>
<sequence key="MyMediator"/>
<property name="RESPONSE" value="true"/>
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
<property name="ContentType" value="text/html" scope="axis2"/>
<enrich>
<source type="property" clone="true" property="RESPONSE_MSG"/>
<target type="body"/>
</enrich>
<send/>
</inSequence>
So, I put the string variable with the html (got from the mediator MyMediator, which is a java class and invoke the webpage www.mypage.com) into a property 'RESPONSE_MSG' and then try to write it to the body (enrich).
In this case I get an error, because the property I set is a String and not a XML. If I use a payloadFactory instead of an enrich, then it will generate an XML and I will get the html tags with <html>.
I would like to know an effective way where I can send the string variable from the mediator and it does not get transformed into some xml where all the html tags into the string gets replaced by < and >. Or I can send it like in the above code without getting any error. Do I have to use another type for the variable that I put in the property RESPONSE_MSG?
Thanks in advance!
This is a problem of the used messageFormatter (text/html). Check your axis2.xml file in the conf directory to see which messageFormatter is configured for the keyword text/html. Otherwise may try with a normal XML builder (i.e. application/xml).