extensionless url in IIS7.5 - asp.net

I have a website, which is been working on Dotnetnuke. I am using dotnetnuke's friendly url to use clean url's instead of asp's ugly QueryString urls, now my problem is, what configuration does it need for the extensionless urls in dotnetnuke using IIS7.5, i checked lots of websites on google, but could not make it, how can i use extensionless urls in asp.net, as Dotnetnuke just allows friendly urls and not extensionless urls.
I even tried using URLRewriter.net, but that too didnt helped.
How can I use extensionless url in asp.net?

I thought your website in 4.0 framework right??
go to iis and site application pool set to classic instead of integrated (Managed pipeline mode:).
then go to your site in IIS and open "Handler Mapping" section and add a "Wildcard Script Map..." Request path = * and Executables = 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" loaproper location of this file and then restart your IIS and run your site.
I hope it will helps you....

I recommend using IIS URL Rewriter with the following rule:
<rewrite>
<rules>
<rule name="Rewrite Tab" stopProcessing="true">
<match url="^([a-z0-9/]+)/tabid/([0-9]+)/([a-z0-9/]+)$" ignoreCase="true"/>
<action type="Rewrite" url="default.aspx?tabid={R:1}"/>
</rule>
</rules>
</rewrite>
This will rewrite
/Category/Subcategory/tabid/123/Default
to
/default.aspx?tabid=123
You might also be able to modify DNN's internal rewrite engine rules.

Have you looked into IIS 7's built in URL rewriter?
http://learn.iis.net/page.aspx/461/creating-rewrite-rules-for-the-url-rewrite-module/

Related

Using IIS rewrite rules to rewrite from main website to sub application

We have an ASP.NET Web API application (.NET 4.*) which is hosted as a website in IIS. The ASP.NET application contains server-side rendered pages, but also a REST API which is available at /api/v1.
A new API is in development, which is using ASP.NET Core (.NET 7) and will be hosted as an IIS application (believe me, we cannot get around that for now) under the main website (which contains the ASP.NET Web API application).
The new API should also be available on /api, but since this is an application under the main website, if we would use /api for the new application, the REST API of the main website would not receive requests anymore. Hosting it under /api/v2 is not possible as IIS applications cannot contain a / in the alias (and we also do not prefer a version in the path anymore).
Instead, we would like to create the application using another name, /foo for example, and use rewrite rules in the web.config to rewrite from the main website to the new application, eg.:
<system.webServer>
<rewrite>
<rules>
<rule name="Foo">
<match url="^api\/((?!v1).*)$" />
<action type="Rewrite" url="foo/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
But this doesn't seem to work. It looks like the request is rewritten, but still handled by the main website, not by the sub application. Is it not possible to rewrite (not redirect!) a request from a website to a sub application within that website? If not, any other suggestions to host both applications on the same starting path (it should remain two separate applications)? At the moment, there is no possibility for a reverse proxy which could solve this issue.
If you want to access requests starting with /api by typing /foo in the browser address bar, you can try the following rule:
<system.webServer>
<rewrite>
<rules>
<rule name="Foo">
<match url="foo(.*)" />
<action type="Rewrite" url="api{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>

Outbound URL Redirect Rule to serve content request from an Azure CDN not working

I wrote a redirect rule that will route client's content requests, to the linked Azure CDN serving my hosted ASP.Net MVC website on an Standard plan.
I tried several iteration of the rule; nothing is working
These are the steps I took to implementation
Create Storage
Create CDN ENDPOINT http:// azxxxxxx.vo.msecnd.net/
Created a subdomain at GoDaddy verified and pointing to azxxxxxx.vo.msecnd.net/
Created a public container using Cloudberry Explorer
Uploaded images blobs to the container and
Tested content availability successfully on the browser at http:// azxxxxxx.vo.msecnd.net/images/test.jpeg
Tested content availability successfully on the browser at https:// storage.blob.core.windows.net/images/test.jpeg
inserted the Rewrite-redirect rule on the site web.config file
<rewrite>
<rules>
<rule name="CDN Redirection" stopProcessing="true">
<match url="^images/(.*)" />
<action type="Redirect" url="http:// azxxxxxx.vo.msecnd.net/images/{R:1}" />
</rule>
</rules>
</rewrite>
......( No using the custom subdomain name yet waiting for propagation)
Save, stop and restart website, clear cache, F12, inspect element .....nothing, content still being pulled straight up from the website
So what am I doing wrong?
Check my website at http://www.ehubcap.net
Thank you
This is a simple rule that is tested and works on Azure Websites:
<rule name="images redirection" stopProcessing="false">
<match url="images/(.*)" ignoreCase="true" />
<action type="Redirect" url="https://double.blob.core.windows.net/images/{R:1}" redirectType="Permanent" appendQueryString="true" logRewrittenUrl="true" />
</rule>
Note, you don't need the ^ in your match pattern.
You can check the result here - check the original page source first - IMG element refers to a local image: http://double.azurewebsites.net/images/some.jpg, which is being redirected by the URL Rewrite to the blob storage (you can redirect to any domain you wish).
Note, however, that URL Rewrite module is dependent on other modules. For best results, the UrlRewrite Module should be the first module to process the result. If you have enabled static and/or dynamic compression to compress the output, the URL rewrite will not work. This is because the default configuration kicks the compression module first, then brings the URL Rewrite module. And the URL Rewrite module cannot read compressed content. Yeah, don't ask me why. So, first disable compression (if you have enabled it) to check the URL rewrite config. Then try to reorder the modules. The simplest would be to first remove them, next add the URL Rewrite and then Compression module.

app_offline.htm not working for rewritten URLs

I have a Rewrite rule for a specific page, to make it more SEO friendly.
<rewrite>
<rules>
<rule name="Friendly Threads">
<match url="Topic/([^/]*)/([^/]*)/[^[#\?]*\??(.*)" />
<action type="Rewrite" url="thread_messages.asp?ThreadID={R:1}&PageNumber={R:2}&{R:3}" />
</rule>
</rules>
</rewrite>
But whenever I drop an app_offline.htm file in the root, the site will go to the app_offline.htm page for all URLs except for those matching the above match.
Is this expected, or have I possibly got something misconfigured somewhere?
If it makes any difference, this is a classic ASP site running under IIS 8 (Windows 2012).
(And yes, I know this is like putting a 90 year old behind the wheel of a Lamborghini.)
As far as I know app_offline.htm only works for ASP.NET. As the rewrite result is classic ASP, the page is handled by another IIS module, so it won't care about app_offline.htm existence.
In another saying, you have done nothing wrong, but classic ASP does not support app_offline.htm.

IIS 7 URL Redirect based on URL path

I have a WCF Web Service hosted inside a ASP.NET 4 environment (IIS 7.5 on Windows 7), and I would like to use URL Rewriting / Redirection.
The reason I need to do this is because I can't change some mobile device code to just insert the parameter.
Here is the URL I want:
http://server.test.com/VirtualDirectory/theOrganization/RequestService.svc/REST/GetIssueTypes
The real URL is:
http://server.test.com/VirtualDirectory/RequestService.svc/REST/GetIssueTypes?organization=theOrganization
Notice how I want to remove theOrganization and appended it to the Query string for redirection.
<rule name="test" stopProcessing="true">
<match url="(.+\.?)/(.+)/RequestService.svc/(.+)" />
<action type="Redirect" url="{R:1}/RequestService.svc/{R:3}?organization={R:2}"
redirectType="Permanent" />
</rule>
I know it's a little odd of a rule to write. Thinks i have my regular expression correct for matching. I run the expression in the URL Rewrite tester in IIS Manager, and it seems like it's matching what I want. Also, I do have IIS URL Rewrite installed, and I made a simple rule up and it worked.
However, when I try it using a browser, it failed to redirect and results in a 404. I was hoping a IIS Rewrite expert could chime in, as I am fairly new at it.
Thanks!
I tested your rule on a test server with iis 7.5 and url rewrite 2.0 and the rule is working, but your regex matches both your wanted url and the real url.
So you end up with a double redirect
I think you want your pattern something like this
(.+.?)/VirtualDirectory/(.+)/RequestService.svc/(.+)
Hope this helps.

What is the correct way to be able to serve up an ASP.NET MVC page with URL /areas?

I am trying to get ASP.MVC to handle the URL /areas i.e. http://example.com/areas. By convention there is a folder called Areas, so /areas never gets to my controller.
I want to be able to tell MVC to ignore this folder in this one case.
Ordinarily I would not use a name that conflicts with an existing folder but I am migrating a web application from Django to ASP.NET MVC and have a section of pages under /areas. I would prefer not to have to change all the existing URL's just because of the framework.
For performance reasons I would prefer not to configure all requests to go through the MVC pipeline.
What other solutions are there?
It might be possible to use the IIS URL Rewrite module to redirect requests to specific folder and avoid the MVC pipeline completely.
The example below is from http://learn.iis.net/page.aspx/496/iis-url-rewriting-and-aspnet-routing/ which shows how to rewrite paths to point at a static resource (Under the heading "Static content management.")
<rewrite>
<rules>
<rule name="Rewrite to new folder">
<match url="^Images/(.+)$" />
<action type="Rewrite" url="NewImages/{R:1}" />
</rule>
</rules>
</rewrite>
I'm curious if you could use an IgnoreRoute in your global.asax.cs file which would cause MVC to ignore that completely and not use the MVC processor for anything in that folder
routes.IgnoreRoute("areas/{*pathInfo}");

Resources