Customize the request to get data from another URL resources - asp.net

The situation is as follows: a CMS system (close source) doesn't use friendly URLs in the manner that we want. It add sub-maps and a static .aspx file and we don't that. Example: the CMS recognizes this: /public/submap/bla/page.aspx?id=CONTACT (page 'contact' in this example). But we want friendly URsL for this page like this: /contact.
My goal: before the CMS engine renders the page, that an incoming request (/contact) will change to the CMS recognized URL (/public/submap/bla/page.aspx?id=CONTACT) but the browser doesn't see this.
I've tried this on some pages with HTTPModule (interface IHttpModule, event BeginRequest) but the only possible way is to redirect 300 to the browser (it will recevied '/contact' and do a redirect to /public/.../page.aspx?id=CONTACT which the browser address toolbar shows).
It there a manner to 'fake' the CMS engine that will recognized it's own URL but between browser and ASP.NET an another URL?
Environment: IIS6 (Windows 2003) and .NET Framework 3.5/4.0.

Server.tranfer is the solution.

Related

What are reliable ways to identify/spot a single page application (SPA)?

When viewing a web application as a user, what are some reliable ways to determine if the app is a single page application (SPA)?
Depending on the framework used, the URL might make extensive use of hashtags. IF you click on navigation links, etc and the URL looks like http://somesite/#/some/route, then it is using hashtag-based routing and is a SPA. Angular 1.x did this for a while. However, newer routing engines use HTML5 features that make the route look like a normal URL: http://somesite/some/route. This URL would be indistinguishable from a non-SPA site. In that case, the only way to tell it is a SPA is to look at the javascript code (Does it use a SPA framework) and/or network traffic (when you click a link does it get the whole page, or just some JSON needed for the current view).

ASP.NET page formatting does not works

I have deployed an ASP.NET website on IIS 7. I was able to access my site using the URL http://**local host**/sitename.aspx and all the formatting of my pages is looking good.
But when I access the same page by using the URL http://**servername**/sitename.aspx from another system or on the same server where I have been deployed, the page formatting is not working properly.
What would be the best solution for this? Thanks
First a fall to check your Js/Css file path where you have not mention static file path with localhost name.
For more detail go to browser and browse your url and press F+12 so development tool will be open and check there for broken url.
I am not sure why you are worrying about formatting soo much. I mean formatting should not affect you much unless you use <pre> in your html.
There are ways to modify the HTTP Response Using Filters. Can you please makesure none of these filters present in your application for release mode.
Generally i use HTTP compression feature of IIS to compress my content, but in browser it looks correct to me.

Single page app in AngularJS and ASP.Net works fine, but when I refresh my page in the browser I get 404 errors

So I've set up an HTML5 single page application, and it's working well. The page is at /App/ and when some one goes to content it looks like /App/Content/1234.
One problem: If the user refreshes the page the server can't find that URL because it doesn't actually exist. If I send them to /App/#/Content/1234, they're golden, but what is the best way to do this? I have a LOT of different styles of URL under /App.
What is the best way to globally catch any request under ~/App/(.*) and redirect it to ~/App/#/$1?
The only route registered in MVC is the standard OOTB route.
Sounds like your server is not re-writing the urls to the app's base URL.
The URL re-writing needed on the web server is server-dependent. For Apache, you'd use mod_rewrite.
Instead, switch Angular to the "Hashbang mode" (the default) so the urls will all store the local state after the # in the url.
I don't want my apps to require server configuration changes, so I recommend hashbang mode.
See AngularJS docs. See section "Hashbang and HTML5 Modes" The HTML5 mode section describes all the configuration issues needed to support HTML5 mode for the urls.
This awesome dude describes how to fix this here.
In brief:
Remove MVC nugets (unless you use MVC controllers for anything) -
you can keep the Web API nugets. Keep WebPages and Razor packages.
Also delete MVC controllers and views.
You can keep using .cshtml
files with some web.config modifications. You'll need this for
bundling.
Finally you add a rewrite rule on web.config to point all urls (excluding content, images, scripts etc) to index.html

What is the recommended method of HTTP Redirection from multiple URLs to one URL?

I have a website that has a number of URLs that people use to connect to that site (uses the bindings on the IIS website and everything works as intended):
http://www.sample.com
http://sample.com
https://www.sample.com
http://xyz.sample.com
http://oldurl.com
Now what I want to do is have all of the URLs go to https://www.sample.com - so if you type in "http://xyz.sample.com" or "sample.com" you should go to https://www.sample.com
The question is what is the best mechanism to do this? I have one possible solution (which I will put as an answer to this question), but I get the feeling that there might be another, better solution available.
One possible option via IIS settings would be to do the following:
Remove extra site bindings from website (i.e. xyz.sample.com, sample.com, etc...). This should leave just the web url you are trying to get all traffic to flow to (i.e. https://www.sample.com)
Create a second website in IIS
In the second website create bindings that were removed from the original website
In the second website use the HTTP Redirect (option in IIS) to direct all traffic from the second site (where all the alternate urls now reside) to the goal site (https://www.sample.com)
Set up a new website on the new binding https://www.sample.com, and then, on the old website, open the Http Redirect property page and set up your redirect.
That's in IIS Manager.

SEO friendly URL in Classic ASP?

I have website developed in classic ASP. The URL is not SEO friendly at present.
Please suggest how I can make the SEO friendly URL for my website in ASP.
Is there any supporting functions which can help in creating SEO friendly URL in ASP?
URL for product Information page like this :
http://www.yourdomain.com/store/template/template2/Default.asp?mainpage=product_info&P_ID=18047
Thanks for your help.
I have read the documentation and Installed the IIRF properly.Now i have few queries.I tried few sample with redirection and they are wrking.I put the clean URL in address bar and result shows data from the original URL.
My Problems: I am still bit confused abt the rewrite and redirect.I don't expect you to teach and guide me for the same.Please pardon me if i write confusing sometime.Please feel free to guide me if i am wrong in approach for SEO friendly URL's.
My Goal is to create SEO friendly URL's for my shopping cart.what I want when page gets parsed in browser it should show the Parsed links as SEO friendly not the original one.
As in my sample when i type URL in address bar it didn't gets changed to clean URL. When i type the clean URL in address bar it shows the data from original URL.
In my shopping cart there are lot of Hyperlinks to other pages.They are also in Dynamic in nature not the static one.How can i set those static hyperlinks to clean URL using IIRF without making substantial changes in my cart.
regards,
Sunny
Configure IIS to do URL Rewriting. Microsoft has an addon for IIS7 (Vista, Server 2008), but you can install IIRF (open source) in IIS5.1 (XP) and IIS6 (Server 2003).
Let all incoming requests or any path starting with /media/ (or pick your own) go through un-rewritten. Only put static files in there such as CSS/JavaScript/images.
Rewrite all incoming request URLS from, e.g., /foo/bar?abc=xyz to /index.asp/foo/bar?abc=xyz. The rewriting is all internal to IIS so the end-user does not see any URL rewriting.
Within index.asp, you can access the original incoming URL /foo/bar via
<%= Request.ServerVariables("SCRIPT_NAME") %>
<%= Request.ServerVariables("PATH_INFO") %>
<%= Request.ServerVariables("QUERY_STRING") %>
yielding
/index.asp
/foo/bar
abc=xyz
We have used isapi rewrite before and it works very well, very configurable per site etc
http://www.isapirewrite.com/

Resources