Thursday, June 23, 2011

Making Http to redirect to Https

There are few ways to achieve this, like through codes and creating another IIS instance to point to HTTPs enabled IIS instance. However all of these approach is not elegant.

There are a way to achieve this, here is the checklist

1. IIS 7 installed
2. Microsoft URL Rewrite Module installed
3. Create HTTPS bindings to your IIS website and assign certificate
4. Ensure Require SSL is NOT checked under SSL Settings for your website

lastly the config changes in web.config.

Link is http://www.iis-aid.com/articles/how_to_guides/redirect_http_to_https_iis_7















Wednesday, June 22, 2011

Exception: System.UnauthorizedAccessException Message: Access to the registry key 'Global' is denied. Source: mscorlib

To add the user a different way:

Go to the Start menu in Windows 7.
Type "Edit Users" in the search box.
Open "Edit Local Users and Groups".
Go to the groups folder.
Right-click on the "Performance Monitor Users" group and go to properties.
Click the Add... button.
Type in "IIS APPPool\DefaultAppPool" and click Check Names.
Click OK and you should be good to go.

Rather than the net localgroup "Performance Monitor Users" defaultapppool /add

Copy Pasting Config files under App_Config cause the website to throw Null Ref Exception

Server Error in '/' Application.
________________________________________
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
Sitecore.Diagnostics.Log.Error(String message, Exception exception, Type ownerType) +132
Sitecore.Diagnostics.Log.Error(String message, Type ownerType) +45
Sitecore.Configuration.Factory.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +682
Sitecore.Configuration.Factory.LoadAutoIncludeFiles(XmlNode element) +77
Sitecore.Configuration.Factory.GetConfiguration() +230
Sitecore.Diagnostics.LoggerFactory..cctor() +67

[TypeInitializationException: The type initializer for 'Sitecore.Diagnostics.LoggerFactory' threw an exception.]
Sitecore.Diagnostics.Log.Error(String message, Exception exception, Type ownerType) +84
Sitecore.Diagnostics.Log.Error(String message, Type ownerType) +45
Sitecore.Configuration.Factory.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +682
Sitecore.Configuration.Factory.LoadAutoIncludeFiles(XmlNode element) +77
Sitecore.Configuration.Factory.GetConfiguration() +230
Sitecore.Configuration.Factory.GetConfigNode(String xpath, Boolean assert) +86
Sitecore.Configuration.Factory.GetConfigNode(String xpath) +29
Sitecore.Resources.Media.UploadWatcher.InitializeIgnoreList() +100
Sitecore.Resources.Media.UploadWatcher..cctor() +51

[TypeInitializationException: The type initializer for 'Sitecore.Resources.Media.UploadWatcher' threw an exception.]

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +86
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +230
System.Activator.CreateInstance(Type type, Boolean nonPublic) +67
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1051
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +111
System.Web.Configuration.Common.ModulesEntry.Create() +39
System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +156
System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1219
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +97
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +188
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +295
System.Web.HttpApplicationFactory.GetPipelineApplicationInstance(IntPtr appContext, HttpContext context) +56
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +231

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8909915
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +85
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +333


Just today as part of config files sync, I have migrated config files across environment, however after I have migrated config by means of copy pasting the file (i.e. rather than opening up editor and copy pasting content). it cause the website to go down. The error is as shown below.

I have tried to
1. Restoring the backup config files (i thought the config files that cause this issue) That doesnt fix it.
2. Restart IIS
3. Restart apppool
4. Reassigning security settings

All of the above doesnt work. So i decided to create brand new IIS Instance and point the physical path to the webroot (with the config changes implemented).

it works!! I conclude somehow the IIS/Apppool must have gone crazy A.K.A corrupted.

However there are times we have implemented lots of setting to the IIS Instance (e.g. whitelisted IPs, SSL certificate, header expiry). it will be a pain to set this up again. Luckily i didnt just delete the old IIS instance. So I try to narrow down the cause of the issue, i try to point the old IIS instance Apppool to the newly created APPPool, and viola it also works! So now i know something must have gone wrong in APPPool. I try to play around with the old APPPool, but in the end i recreate the APPPool with the same name and now it works just like per normal.

Friday, June 17, 2011

MultiEnvironment Setup (1 Content Author + 3 Content Delivery) not clearing cache


Recently, I have been struggling trying to find a solution to a problem whereby Sitecore MultiEnvironment setup is not clearing cache in Content Delivery upon publishing from Content Author.

The setup for this Sitecore project is as above. I eventually contacted Sitecore support for help to troubleshoot this issue. After several days of back and fourth email, we managed to fix the issue! The cause of this problem is ForwardingSecurityEvents.config, i turn this on initially when trying to forward security events. However as our CD doesnot requires any login, this is now deemed as unncessary. So I rename to ForwardingSecurityEvents.config.example From this i learned a few things,

1. in ForwardingSecurityEvents.config, there is a setting false which cause the events to be ignored.
2. clear cache works for all CD IIS isntance even though they are sharing the same CD database

Friday, June 10, 2011

Configuring Production server

http://sdn.sitecore.net/upload/sdn5/developer/configuring%20production%20environments/configuring%20production%20environments.pdf

A really good article on how to configure production server

Thursday, June 9, 2011

SQL Login failed for user

Today, I have come across a strange issue whereby connection to SQL DB is not valid from connection string but it the login is fine through SQL Management Studio.

The error i have received is as such;

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'user'.

To solve this issue, I have forced any connection to SQL Server to use TCP/IP. this is done by disabling all other protocol (e.g. Name Pipes and Shared Memory) using SQL Server Configuration.

Note: the SQL Database is clustered, which adds to the complexity.