• Asp.Net
  • MVC
  • C#
  • SQL Server
  • JavaScript
  • Learn from Life

Prakash Rathod

~ Passion is not a logic; it's an emotion.

Prakash Rathod

Monthly Archives: September 2013

God of India

22 Sunday Sep 2013

Posted by Prakash in Life - Spiritual - Reality, Uncategorized

≈ Comments Off on God of India

In India, everyone has own God and different mentalities and rules given by the God. Moreover everyone’s God is a supreme of God(s). Indian always follows a man who has ability to hypnotist anyone, to give good speech, etc. Indian who are rich men follow that kind of person for making them black money to white, for vote and etc. Why an Indian does not understand, a person never be a God except a gentleman/ Sant / Sadhu? I feel, India is a big market place for becoming a God or Guru and getting all facilities without paying a single penny and selling products without waste money in advertisement. I remember a line of OMG movie, “Jahan dharm hai na, wahan satya ke liye jagah nahi hai … aur jahan satya hai truth hai, wahan dharm ki zaroorat hi nahi hai”…. Hope every Indian understand and enjoy and grow life in real a way…

404 error WCF on server

20 Friday Sep 2013

Posted by Prakash in Asp.Net, Uncategorized

≈ Comments Off on 404 error WCF on server

Add below lines undser System.Server / handler section.

<add name="svc-ISAPI-2.0" path="*.svc" verb="*" modules="IsapiModule" scriptProcessor="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
     <add name="svc-Integrated" path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" resourceType="Unspecified" preCondition="integratedMode" />

   

Auto redirect domain.com to www.domain.com using javascript

04 Wednesday Sep 2013

Posted by Prakash in Uncategorized

≈ Comments Off on Auto redirect domain.com to www.domain.com using javascript

var data = window.location.href;
	if(data.indexOf('http://www.')==0){		}
else{ var newurl = data.replace('http://', 'http://www.');window.location  = newurl;}	

Add the above lines in under script in head tag section in every html page.

Import SSL, Auto redirect http to https, Custom Error Page lock violation

04 Wednesday Sep 2013

Posted by Prakash in Asp.Net, Netoworking, Uncategorized

≈ Comments Off on Import SSL, Auto redirect http to https, Custom Error Page lock violation

Import SSL in IIS 7

For importing SSL certificate, the certificate should have in PKCS #12 format (.pfx). If you have SSL certificate, its not in PKCS #12 format and you have Certificate and Private key you can generate the .PFX SSL certificate using OPENSSL tool or online by click here.

Once the .PFX certificate generated, go to IIS Manager by type ‘inetmgr’ in windows run. Select main not in left pane. And double click on “server certificates” from the middle pane. Then click on ‘import’ from the right pane. A dialog box will open select the SSL certificate which you have generated in .PFX format and enter the password which you had given at the time of generating the PFX certificate. Click on Ok button. Now, you can assign the certificate to your domain, using Binding.

Auto redirect http to https in IIS 7
Method 1 – Using Microsoft URL Rewrite Module

For this method of redirecting from HTTP to HTTPS, you will need to do the following;

1. Install the Microsoft URL Rewrite Module
2. Install your SSL certificate in IIS 7 and bind it to your website
3. Make sure Require SSL is NOT checked under SSL Settings for your website
4. Copy and paste the following code between the and tags in your web.config file in your website root directory.

<rule name="HTTP to HTTPS redirect" stopProcessing="true">
  <match url="(.*)" />
    <conditions>
      <add input="{HTTPS}" pattern="off" ignoreCase="true" />
    </conditions>
  <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>

5. Test the site by going to http://www.yoursite.com and making sure it redirects

Method 2 – Setting up a Custom Error Page
The second method of setting up an IIS7 redirect HTTP to HTTPS is to Require SSL on the site or part of the site and set up a custom 403.4 error page. To do this, just following these steps:

1. Install your SSL certificate in IIS 7 and bind it to your website
2. In IIS, click on the site name, and go to the SSL Settings section
3. Check Require SSL checked under SSL settings of your website
4. After doing this, users will normally receive this error 403.
5. Create a new text file and paste the following into it:

<html>
<head><title>Redirecting...</title></head>
<script language="JavaScript">
function redirectHttpToHttps()
{
    var httpURL= window.location.hostname + window.location.pathname + window.location.search;
    var httpsURL= "https://" + httpURL;
    window.location = httpsURL;
}
redirectHttpToHttps();
</script>
<body>
</body>
</html>

6. Save the file as redirectToHttps.htm in your C:\Inetpub directory
7. Back in IIS, click on the site name and double-click the Error Pages option
8. Click Add… and enter 403.4 as the Status code. Browse for the redirectToHttps.htm file you just created and click OK
9. Select the error code and press Edit Feature Settings…
10. Click the Custom error pages option and again browse for the redirectToHttps.htm file
11. Test the site by going to http://www.yoursite.com and making sure it redirects

Custom Error Page lock violation

If your IIS 7 web server doesn’t already have it, install the IIS 7.0 Administration Pack from Microsoft.

Navigate to the root web server name in IIS, and open the Configuration Editor (part of the Administration Pack). Change the dropdown to system.webServer/httpErrors, right-click on defaultPath, and choose ‘defaultPath’ Attribute -> Unlock Attribute.

Then try to change the custom error handler page again. Navigate to your site, open Error Pages under the IIS group, click Edit Feature Settings on the right, select Custom error pages and finally, put in your path for the default page.

The Manual Way

I know you can accomplish all this by direct editing in notepad of the appropriate config file on the web server. And that may be required for your particular web hosting environment or company production web server change protocols. But why make it complicated if it doesn’t need to be? Plus, this way you can do it in the GUI, and compare the before and after to see what changes you truly have to make. But if you MUST do it manually, then:

Open the file %windir%\System32\inetsrv\config\applicationHost.config in Notepad. Run Notepad as administrator if you’re having problems.

You’ll see something like this:

<httpErrors lockAttributes="allowAbsolutePathsWhenDelegated,defaultPath">

Remove the ,defaultPath section and save.

You will be able to make the changes you need.

Recent Posts

  • Create a custom autocomplete control in ASP.NET MVC
  • Nth Highest Salary
  • Generate x509 certificate in pem, cer and pfx and export public key
  • Send an image (stored as base64 string) inline in email
  • Put/Delete http verb not working server

Categories

  • Android
  • Asp.Net
  • BANKING
  • c#.net
  • Crystal Report
  • HTML5 CSS3
  • iPhone
  • JavaScript
  • Life – Spiritual – Reality
  • Lightswitch
  • Links
  • MAC
  • MVC
  • Netoworking
  • Silverlight
  • SQL Interview Questions
  • SQL Server
  • Uncategorized
  • Version Controls
  • Windows Store

Archives

  • August 2019
  • May 2019
  • April 2018
  • October 2017
  • August 2017
  • April 2017
  • March 2017
  • February 2017
  • December 2016
  • April 2016
  • January 2016
  • November 2015
  • January 2015
  • December 2014
  • October 2014
  • September 2014
  • June 2014
  • April 2014
  • March 2014
  • February 2014
  • December 2013
  • November 2013
  • October 2013
  • September 2013
  • July 2013
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • November 2012
  • October 2012
  • September 2012
  • July 2012
  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • October 2010
  • September 2010
  • August 2010
  • July 2010
  • June 2010
  • May 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009

© 2021 Prakash Rathod