URL Rewrite outbound rule examples

Here I’m providing short examples with ui rules only. I’ll assume you have some knowledge in URL Rewrite otherwise I’ll suggest you to read official documentation at http://www.iis.net/learn/extensions/url-rewrite-module/using-the-url-rewrite-module

I’m listing below some examples in the form of questions and how to solve them

Outbound rules

Note: in some of the outbound rules precondition responseHtml1 configured as below

1) Add custom script at the end of the response html

2) Add custom script at the beginning of response html

3) Rewrite subdomain with different domain with same URL path and query

Example:  I want to rewrite

https://domain1.rajbandi.net/examples/urlrewrite/domain1.aspx

as

https://domain2.rajbandi.net/examples/urlrewrite/domain1.aspx

Only domain part is changing, path and query is same.

4) Modify redirect location domain to a different domain with same path and query only when particular words exists.

For example:

Modify response header location if path starting with accounts or customer to different domain

http://www.rajbandi.net/account/login.aspx  or http://www.rajbandi.net/customer/login.aspx

to

http://www.rajbandi.com/account/login.aspx or http://www.rajbandi.com/customer/login.aspx

5) Remove body onload function in response html

Actual

;

Expected

;

6) Find all the links with some text and prevent click on them

Actual

Click here to visit rajbandi.net;

Expected

Click here to visit rajbandi.net

Alternatively, you can attach some javascript(preventDefault or something) to href

I’ll update more examples asap.

Portable class library with asmx soap service

Recently I was working on a portable class library(PCL) example in VS2012 to create a proxy class for an external asmx soap service with return types DataTable and DataSet. The easiest way to create a proxy class to add a service reference. In my case, it failed. The add service reference generated code  contains XmlElement and failed to generate response messages with DataTable and DataSet. VS2012 gives a warning for Xml Element.

The alternative way to add service reference is to create a HttpWebRequest to asmx service wsdl and use System.ServiceModel.Description.ServiceDescription to load response xml and parse WSDL. This is one too not supported in PCL.

Because of these limitations, What I think a work around for this is to create a custom wsdl parser or manually construct soap envelopes and parse responses but its not an easiest way to do it and a time consuming.

Some of the limitations of PCL are

1) PCL doesn’t support System.Xml.XmlElement, instead use System.Xml.Linq.XElement

2) PCL doesn’t support System.Data.

3) PCL doesn’t support some of the member classes of System.ServiceModel.Description for example ServiceDescription, WSDLImporter etc.

My project target settings as below