Showing posts with label IIS 7.0. Show all posts
Showing posts with label IIS 7.0. Show all posts

Wednesday, October 05, 2011

Fix it: IIS Manager doesn't update web.config when you add HTTP Response headers in Azure

Hi All,

I was trying to disable Silverlight caching in IIS 7, and when i deployed my solution to Windows 2008 Ent. in Windows Azure. Every time you click on the xap file that i need to disable caching on it by checking expire web content immediately after i clicked on Set Common Headers link on the right pane, the web.config is not being updated at all. but this works on my local IIS.

I ended up with adding this attribute that has been added my local IIS to web.config and deploy it so i don't need to do this every time i perform a deployment.

<system.webServer> 
     <staticContent> 
      <clientCache cacheControlMode="DisableCache" /> 
    <staticContent>       
<system.webServer>


To disable caching in Silverlight "xap" file from IIS, Here is the article that i'm referring to:



Hope this tip helps.

Regards,Mostafa Arafatwitter.com/mostafaelzoghbi

Monday, May 16, 2011

Automatic HTTPS redirect in Windows 2008 R2

Hi All,

I was trying to setup automatic redirect from HTTP to HTTPS for my hosted web application in IIS 7.0/7.5 Windows 2008 R2. I spent good time trying to find out a working solution for this problem.

If you tried a solution with custom error pages 403 in IIS to redirect the http to https, this won't work in windows 2008 R2 IIS 7.0/7.5 server, as stated here:


Please follow these steps to have a working solution:
1) Install URL Rewrite 2.0 on your webserver, download url:

2) After installing url rewrite module in IIS, Open IIS Manager and select your website, you will find a newly added icon "Url Rewirte"

3) Make sure to install SSL certificate on your site and site has https binding on port 443.

4) on SSL settings in IIS, un check Require SSL check - IMPORTANT, because this will overwrite the settings you will configure on URL Rewrite and will throw http 403.4 error.

5) Don't add any custom error pages for 403 as mentioned on some blog posts, if you have please remove it.

6) double click on URL rewrite and click on add rule.

7) Select Blank rule and click on ok.

8) On Name field give name to the rule: Redirect to HTTPS

9) Set the following values on the form:
- Requested URL: Select Matches the pattern
- Using: Regular Expression
- Pattern: (.*)
- Under Conditions, Click on Add and type:
Condition Input: {HTTPS}
Check if input string: Matches the pattern
Pattern: ^OFF$
- Under Action section:
Action Type: select Redirect
Redirect URL: https://{HTTP_HOST}{REQUEST_URI}
If you tried this url: https://{HTTP_HOST}/{R:1} as stated in some blogs, this won't work as well.
Redirect Type: See Other (303)

And then click on Apply.

From IIS Manager, Try to browse the application using HTTP, The IIS will direct you to HTTPS automatically.


Hope this helps.

Resources:



Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Monday, May 09, 2011

Unrecognized attribute 'targetFramework' 4.0

Hi Folks,

If you tried to deploy your asp.net application on Win 08 - IIS7 and you were getting this error:
Unrecognized attribute 'targetFramework' 4.0

This means the application pool that runs your website is not configured to run under .NET Framework 4.0.

On IIS 7:
1) Click on your application pool.
2) Click on the right pane, Advanced settings.
3) Under General Tab, Select .NET Framework Version.
4) Select v 4.0.
5) Recycle your application pool by right click on it.
6) Refresh your page.

Refresh your page and it works :)

Hope this helps...


Regards,
Mostafa Arafatwitter.com/mostafaelzoghbi

Tuesday, September 14, 2010

Bing Maps troubleshooting WCF services: Geocode Service

Hi All,

I was developing a WCF service that consume Bing Maps Geocode Serivce, and when i was trying to create an object from the geocodeservice, i was getting this error :

{"An endpoint configuration section for contract 'GeocodeService.IGeocodeService' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name."}

C# Code for creating a Geocode service object:

GeocodeServiceClient geocodeService = new GeocodeServiceClient();

This is beacause i have more than endpooint for my service, please check your Web.Config or the service configuration file if your WCF is not hosted within web application. You will find at least 2 endpoints are defined for your service, To fix the problem :

1) Either to remove one of the endpoints definition.
2) Keep all endpoints and select which endpoint you want to use in your code - This is the preferred solution.

C# Code for the fix : 2nd option


GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService");

I selected the basic HTTP binding for my service. and you can select any of your choice and you have to specify this in your code.

Hope this helps.


Regards,Mostafa Arafatwitter.com/mostafaelzoghbi

Wednesday, July 07, 2010

WebMatrix and RAZOR for web development with no cost

Hi All,

Microsoft released the WebMatrix platform (FREE) that has all you need to build any websites, with WebMatrix you can do:
1) Design your websties.
2) Develop/Deploy your websites using RAZOR: is a new declarative simple language to build your websites.
3) Platform support ASP.NET, WebForms, MVC, AJAX, CSS and all the power of .NET Framework.
4) It’s just 15 M to download.
5) It includes IIS Express, SQL Compact,.NET Framework runtime and all you need to develop websites.
6) Scale up your sites to VS 2010 and SQL Server 2008 if required.
7) Download and build websites on open source CMS such as Word Press, Drupal 7, PHP and MySQL.
8) More….

Get a quick tour:
http://www.microsoft.com/web/default.aspx

Code without boundaries using WebMatrix and start developing websites with no cost for the tools :)

Regards,
Mostafa Arafa
twitter.com/mostafaelzoghbi

Monday, July 21, 2008

Get Started with IIS 7.0

For All web developers, very useful post for getting started with Configuring asp.net applications on IIS 7.0 on vista and windows Srvr 2008 :

http://www.dotnetbips.com/articles/df885319-19cc-47b8-8808-6ed462db1de5.aspx

hope this helps.

Regards,
Mostafa arafa