locked
Distinguish Web application and website using response/request Headers in c# RRS feed

  • Question

  • I am stuck in a situation where i have a bunch of url and i have to distinguish them based on whether they belongs to website or webapp.

    I tried to look at Response Header from the request and discovered that i can use server field & powered By field to check it.

    But for most of the requests they are disabled so is there any other way to distinguish webapps from websites.
    • Moved by Kristin Xie Wednesday, February 25, 2015 8:37 AM
    Tuesday, February 24, 2015 4:49 AM

Answers

  • Hello Ashish,

    X-PowredBy is request header generally in applicationhot.config of IIS at below location. This can be added if not exists. This feature exists in IIS 7 and above.

    C:\Windows\System32\inetsrv\config

    The Best solution is to add custom request header to distinguish between Website and web application urls.

    In this situation, you can take leverage of custom header feature which is there in IIS 7 and above.

    you can add this element in web.config file of your website and web application. For example below configuration will add app-PoweredBy request header with "website".

    <configuration>
       <system.webServer>
          <httpProtocol>
             <customHeaders>
                <add name="app-PoweredBy" value="WebSite" />
             </customHeaders>
          </httpProtocol>
       </system.webServer>
    </configuration>

    Below is detailed documentation on Custom header feature.

    http://www.iis.net/configreference/system.webserver/httpprotocol/customheaders

    Hope, this will help you out.


    If this post answers your question, please click Mark As Answer. If this post is helpful please click Mark as Helpful.

    • Proposed as answer by Tejas T Thursday, February 26, 2015 4:42 AM
    • Marked as answer by Just Karl Friday, April 17, 2015 8:01 PM
    Tuesday, February 24, 2015 9:10 AM
  • Hi,

    Thanks for posting in MSDN forum

    For Webapps questions related to ASP.NET use the ASP.NET forum     
    You should get more, better and faster answers on the other forum.  Thanks, ahead of time.

    Have a nice day!

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Just Karl Thursday, April 9, 2015 9:22 PM
    • Marked as answer by Just Karl Friday, April 17, 2015 8:01 PM
    Wednesday, February 25, 2015 8:36 AM

All replies

  • Hello Ashish,

    X-PowredBy is request header generally in applicationhot.config of IIS at below location. This can be added if not exists. This feature exists in IIS 7 and above.

    C:\Windows\System32\inetsrv\config

    The Best solution is to add custom request header to distinguish between Website and web application urls.

    In this situation, you can take leverage of custom header feature which is there in IIS 7 and above.

    you can add this element in web.config file of your website and web application. For example below configuration will add app-PoweredBy request header with "website".

    <configuration>
       <system.webServer>
          <httpProtocol>
             <customHeaders>
                <add name="app-PoweredBy" value="WebSite" />
             </customHeaders>
          </httpProtocol>
       </system.webServer>
    </configuration>

    Below is detailed documentation on Custom header feature.

    http://www.iis.net/configreference/system.webserver/httpprotocol/customheaders

    Hope, this will help you out.


    If this post answers your question, please click Mark As Answer. If this post is helpful please click Mark as Helpful.

    • Proposed as answer by Tejas T Thursday, February 26, 2015 4:42 AM
    • Marked as answer by Just Karl Friday, April 17, 2015 8:01 PM
    Tuesday, February 24, 2015 9:10 AM
  • Hi,

    Thanks for posting in MSDN forum

    For Webapps questions related to ASP.NET use the ASP.NET forum     
    You should get more, better and faster answers on the other forum.  Thanks, ahead of time.

    Have a nice day!

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Just Karl Thursday, April 9, 2015 9:22 PM
    • Marked as answer by Just Karl Friday, April 17, 2015 8:01 PM
    Wednesday, February 25, 2015 8:36 AM