Tuesday, November 23, 2010
CryptographicException : The Parameter is incorrect
Monday, October 4, 2010
Specifying default ISO
By default, ISO setting in web.config is empty. This default the region formatting such as date to be American. E.g. instead of 30/12/2010, it becomes 12/30/2010.
The line of config in web.config to specify this ISO code is
<setting name="DefaultRegionalIsoCode" value="en-AU"/>
Wednesday, August 11, 2010
No .ASPX extension (Extensionless page)
To achieve the goal as mentioned in title, you will need to set the IIS as follow:
1. Open IIS Manager
2. Go to the website instance you want to configure, right click and click property.
3. Click Home Directory
4. Click Configuration
5. Under Wildcard Applications Maps, add the following DLL
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
6. Hit OK
Untick "verify that file exists" if you want a hybrid.
Thursday, August 5, 2010
ACL error.
Today i encountered an issue where i cant access any page and always given a ACL error.
I fixed it by adding "Users" to Security with the following access
1. Read & Execute
2. List Folder Contents
3. Read
Tuesday, July 27, 2010
Icons within sitecore pages not displaying
I have encountered issues whereby the icons on the sitecore portal isnt being displayed. Turn out the issues was with APP_DATA folder having wrong security permission.
it needs to have "Network Service" with write access.
Tuesday, June 29, 2010
Access Denied
Just today, i was given an issue to solve a weird problem to Sitecore Website version 5.3. For some reason it keeps throwing access denied with query string item = /default. I was expecting something like item = /sitecore/content/root.
The issue turn out to be content item being protected. After unprotecting the item and made a publish. the website comes back to life
Monday, June 14, 2010
Query String library
Just want to share or perhaps to remind myself of a very good Query String manipulation library made by Uwe Keim
Monday, May 31, 2010
Sitecore file explorer timeout
Recently I have been trying to fix the issue with Sitecore timing out when opening File Explorer which only happens on the Production environment.
I compared all configuration files, dlls files, sitecore files and etc to no avail. Until i try to delete "Temp_old" folder which i believe a backup of temp folder. The folder is huge and it takes forever to delete. That's when I realized that perhaps that's the folder that Sitecore has been waiting to load through File Explorer however because it took forever, it timed out. I then moved this folder away from webroot and voila it works!
As general rules of thumb, backup should have been done away from Webroot.
Anyway I am very glad that it finally resolved!
Wednesday, May 26, 2010
User Manager error when AD is configured
In one of my project, i encountered issue with User Manager when AD is configured. The error is as shown below
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:
|
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927
However, this error is only happening in my dev environment and the issue seems to be when with the AD configuration. Sitecore threw an error when it tries to load user's state. The code below is the code that deal with this loading
and it is located in UserManager.aspx file which is located at
So two solution will be "Edit the AD field configuration" or "Remove the code from the aspx" file
Sunday, May 16, 2010
XSS vulnerability
A library that can be use to prevent XSS issue is Microsoft AntiXSS library. It is preventing XSS issue by encoding the text.
Favicon not appearing for IE
Few days ago, I have been having issue with Favicon not appearing only for IE. The solution that i have tried and worked is when i move my favicon from image folder up to the webroot folder.
I have also researched that favicon will not appear in IE6 if the website hasnot been bookmarked.
Monday, May 10, 2010
Disabling Indexing
There are times where i need to disable indexing for reason such as performance (e.g. when installing huge files)
The following line is the setting for doing just that.
Default
<setting name="Indexing.UpdateInterval" value="00:05:00" />
Set it to 00:00:00 to disable
<setting name="Indexing.UpdateInterval" value="00:00:00" />
Sunday, May 9, 2010
CryptographicException: Padding is invalid and cannot be removed.
Somethings to try when error such as below occur:
1. Recycle application pool
2. Clear cookies
Server Error in '/' Application.
Padding is invalid and cannot be removed.
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.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed.
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:
[CryptographicException: Padding is invalid and cannot be removed.] System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast) +7599262 System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount) +208 System.Security.Cryptography.CryptoStream.FlushFinalBlock() +33 System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo) +225 System.Web.Security.FormsAuthentication.Decrypt(String encryptedTicket) +246 Sitecore.Security.Authentication.AuthenticationHelper.GetCurrentUser() +125 Sitecore.Security.Authentication.AuthenticationHelper.GetActiveUser() +14 Sitecore.Security.Authentication.AuthenticationProvider.GetActiveUser() +15 Sitecore.Security.Authentication.AuthenticationManager.GetActiveUser() +24 Sitecore.Pipelines.HttpRequest.UserResolver.Process(HttpRequestArgs args) +22 (Object , Object[] ) +61 Sitecore.Pipelines.PipelineMethod.Invoke(Object[] parameters) +36 Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +141 Sitecore.Pipelines.CorePipeline.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +134 Sitecore.Pipelines.CorePipeline.Run(String pipelineName, PipelineArgs args) +50 Sitecore.Nexus.Web.HttpModule. (Object sender, EventArgs e) +252 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75 |
Thursday, April 15, 2010
Ducatshell error
Often I encounter error with Ducatshell error. Problem is caused when the permission inherited to sitecore folder is insufficient.
The security that is normally missing is the ISS application pool security
For example, if we have website.localhost as our application pool name,
the security will be : IIS APPPool\website.localhost
The following bat file will apply the security defined as a parameter to folders that generally requires special security permission
icacls WebSite\sitecore\shell\Applications\debug /grant %1:(OI)(CI)M
icacls WebSite\sitecore\shell\Controls\debug /grant %1:(OI)(CI)M
icacls WebSite\sitecore\shell\Override /grant %1:(OI)(CI)M
icacls WebSite\temp /grant %1:(OI)(CI)M
icacls WebSite\upload /grant %1:(OI)(CI)M
icacls Data /grant %1:(OI)(CI)M
To execute the bat file. The following steps are to be taken.
1. Place the bat file on the same folder as the webroot. that is essentially the bat file is a sibling file of webroot
2. Open up Command prompt in admin mode
3. Navigate to the bat file
4. Type in -> .bat "iis apppool\website.localhost"
5. Enter
Thursday, April 8, 2010
WCF - Issues with multiple host header
Often you encounter WCF error such as below:
This collection already contains an address with scheme http. There can be at most one address per scheme in this collection. Parameter name: item
This issue is caused of multiple host header define in IIS settings. There are number of solution to this, one of them is creating custom ServiceHostFactory or another simpler solution is to configure the settings as below
directly under system.servicemodel
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://intranetportal"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
Modification to RSS.NET to allow Sorting of Items
In RssItemCollection.cs
------------------------
///
/// Sorting for RSSItem
///
public void Sort()
{
InnerList.Sort(new RssItemComparer());
}
class RssItemComparer : IComparer
{
public int Compare(object x, object y)
{
return ((RssItem)y).CompareTo((RssItem)x);
}
}
in RssItem.cs
--------------
public int CompareTo(object obj)
{
return this.pubDate.CompareTo(((RssItem)obj).pubDate);
}
Monday, March 29, 2010
RSS.NET
Just last week, I have the need to deal with RSS for one of my project which was done in Sitecore .Net. That’s when I came across RSS.NET. It is pretty cool, neat and best of all, it is open source .NET library. Meaning you are free to use and tweak the code.
Below is a brief introduction of RSS.NET
“RSS.NET is an open-source .NET class library for RSS feeds. It provides a reusable object model for parsing and writing RSS feeds. It is fully compatible with RSS versions 0.90, 0.91, 0.92, and 2.0.1, implementing all constructs.”
For those who might be interested in using it. Here is the link.
Thursday, March 25, 2010
Rendering HTML Control from backend without outputing any DIV
Often i want to add control from the back-end and 1 of them asp control we can use to do this is asp panel.
However, asp panel render
html tag when rendered, which sometimes i do not want. Another alternative is to use asp placeholder
Wednesday, March 24, 2010
Converting RSS Feed through URL to XPathNavigator
In one of my project, i was required to read RSS Feed from a website, cache it and then output the RSS feed onto website that i am working on using XSLT.
To accomplish this, I have used open source library or code, they are RSS.Net and CacheHelper
It took me sometime to accomplish these as i run into some problems. They are:
1. XML Document root element missing
2. XML Document element not closed properly which cause memory leakage
After several trials and error, i found out that RssWriter in RSS.Net works fine if you output the xml into a document, however it is not the same case if you were to output it onto a Stream.
So the following code that output RSS onto a file works fine:
var writer = new RssWriter(@"c:\\test.ml");
writer.Write(feed.Channels[0]);
writer.Close();
However the following code that deal with memory stream doesnt work
var rssXmlDoc = new XmlDocument();
var memStream = new MemoryStream();
var writer = new RssWriter(memStream, Encoding.UTF8);
writer.Write(feed.Channels[0]);
writer.Close();
rssXmlDoc.Load(memStream);
-- This will not work, since the stream is already closed
so because of that i thought it should be
rssXmlDoc.Load(memStream)
writer.Close();
-- But this doesnt work as well, because without writer.Close(), the last element is not closed properly.
so I modify the RSS.Net and create a method CloseDocument() that close the element without first closing the writer.
so the code becomes
var rssXmlDoc = new XmlDocument();
var memStream = new MemoryStream();
var writer = new RssWriter(memStream, Encoding.UTF8);
writer.Write(feed.Channels[0]);
writer.CloseDocument();
rssXmlDoc.Load(memStream);
writer.Close();
-- We are almost there. This will still throw an error and the error will be XML Root document element missing
we need to add the following line in red
var rssXmlDoc = new XmlDocument();
var memStream = new MemoryStream();
var writer = new RssWriter(memStream, Encoding.UTF8);
writer.Write(feed.Channels[0]);
writer.CloseDocument();
memStream.Position = 0;
rssXmlDoc.Load(memStream);
writer.Close();
this will move the read/write location back to the start of the stream.
Finally the method that i came out with to get FeedUrl to XPathNavigator is
public class ExternalFeed
{
//Default cache time will be 1 minute
public const int DefaultCacheTime = 60;
public string FeedUrl { get; private set; }
public int CacheTimeInSeconds { get; private set; }
public ExternalFeed(BaseItem definitionItem)
{
if (definitionItem == null)
{
Log.Error("ExternalFeed: definition item is null", this);
return;
}
FeedUrl = definitionItem[Constants.MeltwaterFields.FeedUrl];
var secondString = definitionItem[Constants.MeltwaterFields.CacheTime];
int second;
CacheTimeInSeconds = int.TryParse(secondString, out second) ? second : DefaultCacheTime;
}
///
/// Load data from the external source. to be called after construction
///
/// True if loaded successfully, otherwise false
public bool Load()
{
//Ensure that the URL is valid
if (string.IsNullOrEmpty(FeedUrl))
{
Log.Error("ExternalFeed: Feed Url is empty", this);
return false;
}
var feed = RssFeed.Read(FeedUrl);
CacheHelper.Add(feed, FeedUrl, CacheTimeInSeconds);
return true;
}
///
/// Get the data of the feed
///
/// The feed data
public XPathNavigator GetData()
{
RssFeed feed;
if (!CacheHelper.Get(FeedUrl, out feed)) {
Load();
CacheHelper.Get(FeedUrl, out feed);
}
var rssXmlDoc = new XmlDocument();
var memStream = new MemoryStream();
var writer = new RssWriter(memStream, Encoding.UTF8);
writer.Write(feed.Channels[0]);
writer.CloseDocument();
//This will move the read/write location back to the start of the Stream and allow the XMLDocument to read in the entire contents
memStream.Position = 0;
rssXmlDoc.Load(memStream);
writer.Close();
return rssXmlDoc.CreateNavigator();
}
}
Here is the other code for Closing Document in RSS.NET. The code below is from "RssWriter.cs" class
/// Closes instance of RssWriter.
/// Writes end elements, and releases connections
/// Occurs if the RssWriter is already closed or the caller is attempting to close before writing a channel.
public void Close()
{
writer.Close();
writer = null;
}
///
///
///
public void CloseDocument()
{
if (writer == null)
throw new InvalidOperationException("RssWriter has been closed, and can not be closed again.");
if (!wroteChannel)
throw new InvalidOperationException("Can't close RssWriter without first writing a channel.");
writer.WriteEndElement(); //
writer.WriteEndElement(); // or
writer.Flush();
}
Converting string pubDate to C# DateTime
pubDate format for RSS2.0 - Tue, 16 Mar 2010 11:05:35 GMT
DateTime pubDate;
if (DateTime.TryParse(date, out pubDate))
{
pubDate = Convert.ToDateTime(date);
}
Sunday, March 14, 2010
Lucene Index Viewer
Recently, I have a need to look into Lucene index and after sometime of googling around, I have come across this neat little tool Luke - Lucene Index Toolbox.
Here is the link to download:
Thursday, February 25, 2010
XAML Naming Issues
Recently I have encountered issue with XAML application not displaying. It appears the XML control name that I have which is "AdministerAccess" for some reason this name is causing the XML to cease to render. Perhaps there is conflict with the naming of XAML application.
Tuesday, February 23, 2010
DB not updating
By Default Sitecore cache application data. That means if we have 2 developers sharing the same DB, and 1 developer made an update to Sitecore DB, the other developer will not see the DB changes unless he/she restart his/her application pool.
This generally does not cause much problem, because when we developing, we often build our solution which in turn restarting the application pool at the back.
Wednesday, February 17, 2010
Get Sitecore User creation date
Sitecore User creation date value isnt available readily from Sitecore User object. However, I know it is possible to get the creation date, since in "Edit User" XAML in Sitecore has this field populated.
To find out how Sitecore get the creation date, I have dissected Sitecore.Client.dll. In this dll, I believe (correct me if i am wrong) most if not all of the code behind for Sitecore Application reside in this dll. After tracing through the "Edit User" xml, I found out that the Sitecore.Shell.Applications.Security.EditUser is the code behind for the xml that I am after.
Below is the code to get User creation date.
MembershipUser user2 = Membership.GetUser(user.Name);
if (user2 != null)
{
CultureInfo culture = User.Current.Profile.Culture;
this.LastLoginDate.Text = DateUtil.FormatLongDateTime(user2.LastLoginDate, culture);
this.CreationDate.Text = DateUtil.FormatLongDateTime(user2.CreationDate, culture);
this.LastActivityDate.Text = DateUtil.FormatLongDateTime(user2.LastActivityDate, culture);
this.LastPasswordChangedDate.Text = DateUtil.FormatLongDateTime(user2.LastPasswordChangedDate, culture);
this.LastLockoutDate.Text = FormatDate(user2.LastLockoutDate, culture);
}
Wednesday, February 10, 2010
Moving Search Indexes up to datafolder
Unlike Sitecore 6.2, search indexes for Sitecore prior to 6.2 does not store the search indexes at Data Folder. Due to some glitches or issues for having indexes at webroot folder, it is a better approach to move the indexes at Data Folder. Following is the steps to do just that.
In web.config,
Locate <!-- Simple Settings --> and add the settings in red
<Settings>
<!-- Index folder change for stability -->
<setting name="IndexFolder" value="$(dataFolder)\indexes" />
...
</Settings>
Tuesday, February 2, 2010
RTE Output escaping html sepcial character (e.g. & < >)
Ages ago (last year), I have an issue with RTE inside Sitecore, whereby it tries to escape html special character. E.g. for this is
Solution:
It is proper behavior. Imagine that you will output this RTE text on the frontend. Then ">" and "&" could be read as parts of tags or reserved symbols, so such characters are always escaped.
But you can try to add your handler to save HTML in different way. This could be done by the next steps:
If you make such changes, be sure that you handle double meaning situations properly.
But you can try to add your handler to save HTML in different way. This could be done by the next steps:
Tuesday, January 26, 2010
SSO enabled Sitecore interfere with uploading of media into library
Recently, I faced with an issue whereby when SSO (single sign on) is enabled on Sitecore website and try to upload media onto library, it will prompt for username and password and when valid username and password is entered, it will hang. strangely, it happens for IE7 only. I have tested on IE8 it works fine!
I have logged a support to Sitecore, and the solution that they provided, which was
setting "Upload.Classic" = true in web.config is the solution
Monday, January 18, 2010
WCF - Error 404.3 when trying to access the SVC file
It turns out that WCF is not active by default. Followings are the steps to active WCF
1. Click Start
2. Click Run
3. Type "Optional Features"
4. Tick "Microsoft .NET Framework 3.0 the Windows Communication Foundation HTTP Activate" & "the Windows Communication Foundation non-HTTP Activate"
Wednesday, January 13, 2010
CryptographicException file not found in Sitecore
Today I came across issue with CryptographicException file not found in Sitecore. See below
Server Error in '/' Application.
The system cannot find the file specified.
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.Security.Cryptography.CryptographicException: The system cannot find the file specified.
Source Error:
Stack Trace:
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927
Server Error in '/' Application.
The system cannot find the file specified.
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.Security.Cryptography.CryptographicException: The system cannot find the file specified.
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:
[CryptographicException: The system cannot find the file specified. ] System.Security.Cryptography.Utils.CreateProvHandle (CspParameters parameters, Boolean randomKeyContainer) +7715070 System.Security.Cryptography.DSACryptoServiceProvider.ImportParameters (DSAParameters parameters) +258 System.Security.Cryptography.DSA.FromXmlString(String xmlString) +501 Sitecore.Nexus.Licensing.NexusLicenseApi. (String xml, Guid instance) +138 Sitecore.Nexus.Licensing.NexusLicenseApi.GetSnapShot(Guid instance) +764 Sitecore.SecurityModel.License.LicenseManager.GetSnapshotData(Guid instance) +59 Sitecore.SecurityModel.License.LicenseManager.UpdateSnapshot() +103 Sitecore.SecurityModel.License.LicenseManager.Initialize() +8 Sitecore.Nexus.Web.HttpModule.Application_Start() +76 Sitecore.Nexus.Web.HttpModule.Init(HttpApplication app) +435 System.Web.HttpApplication.InitModulesCommon() +65 System.Web.HttpApplication.InitModules() +43 System.Web.HttpApplication.InitInternal (HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +729 System.Web.HttpApplicationFactory.GetNormalApplicationInstance (HttpContext context) +298 System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +107 System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +289 |
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927
After consulting with my colleague, the solution is to do with IIS settings.
To resolve this,
1. go to IIS Manager
2. go to the application pool instance
3. click advanced settings
4. Under Process model, set Load User Profile to true
Tuesday, January 12, 2010
JQuery JSON disable asynchrounous call
jQuery.ajax({
url: hostBlogUrl + getDaysInMonthWithEntryService,
type: "POST",
contentType: "application/json; charset=utf-8",
data: "{'blogID':'" + pBlogID + "', 'month':" + pMonth + ", 'year':" + pYear + "}",
dataType: "json",
success: function(response) {
var daysArray = response.d;
days = daysArray;
return daysArray;
},
error: function(req, status, er) {
alert("An error occurred whilst submitting your request.\r\n" + status + " " + er);
},
async: false
});
Subscribe to:
Posts (Atom)