"Empty strings are not allowed" error when adding Sitecore placeholder - sitecore

I get the following error message when trying to add a placeholder to a layout in Sitecore 6.5:
"Empty strings are not allowed.<br>Parameter name: xml"
Any idea what could be the problem? The following stack trace appears in the log:
1124 10:20:56 ERROR Application error.
Exception: System.Web.HttpUnhandledException
Message: Exception of type 'System.Web.HttpUnhandledException' was thrown.
Source: System.Web
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.sitecore_shell_default_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\59ed33b7\d6112557\App_Web_edgk4py3.1.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Nested Exception
Exception: System.Reflection.TargetInvocationException
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Sitecore.Reflection.ReflectionUtil.CallMethod(Type type, Object obj, String methodName, Boolean includeNonPublic, Boolean includeInherited, Object[] parameters)
at Sitecore.Reflection.ReflectionUtil.CallMethod(Object obj, String methodName, Boolean includeNonPublic, Boolean includeInherited, Object[] parameters)
at Sitecore.Web.UI.HtmlControls.Component.HandleMessage(Message message)
at Sitecore.Shell.Framework.Commands.ClientEventCommand.SendEventMessage()
at Sitecore.Shell.Framework.Commands.ClientEventCommand.Execute(CommandContext context)
at Sitecore.Web.UI.Sheer.ClientPage.RaiseEvent()
at Sitecore.Web.UI.Sheer.ClientPage.OnPreRender(EventArgs e)
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Nested Exception
Exception: System.ArgumentException
Message: Empty strings are not allowed.
Parameter name: xml
Source: Sitecore.Kernel
at Sitecore.Diagnostics.Assert.ArgumentNotNullOrEmpty(String argument, String argumentName)
at Sitecore.Layouts.LayoutDefinition.Parse(String xml)
at Sitecore.Shell.Applications.Layouts.DeviceEditor.DeviceEditorForm.OnOK(Object sender, EventArgs args)

I encountered this issue and found the source of the issue to be the settings InvalidItemNameChars and ItemNameValidation being blank in the web.config.
I have removed the values to import a packages with invalid characters as soon as I restored the values to the Default values, shown below, the exception stopped occurring.
<setting name="InvalidItemNameChars" value="\/:?"<>|[]" />
<setting name="ItemNameValidation" value="^[\w\*\$][\w\s\-\$]*(\(\d{1,}\)){0,1}$" />

Most commonly, this has to do with your language settings. Like for instance; if your user (via the default Content Language) is set to edit items in a language, the current item you are editing does not have a language specific version for.
So for instance; you're on an item that exists in "en" - and the user you are logged in as; defaults to "da-DK" - AND the current item does not have a version in "da-DK".
I've not seen this bug in a long while though, I would have thought it fixed.
It might not be this issue at all, but it's really hard to tell from the limited information you have on the issue.
Take a look at your user settings; also if there's any "ContentLanguage" attributes defined in your site definition that might not be what you expect.

Related

Could not retrieve Coveo for Sitecore license

Getting below Exception while going through the Control panel of Sitecore.
[LicenseNotFoundException: Could not retrieve Coveo for Sitecore license.]
Coveo.SearchProvider.Licensing.Cloud.LicenseRetriever.GetLicense(Boolean p_ForceRetrieve) +274
Coveo.SearchProvider.Licensing.LicenseManager.EnsureValidLicense() +77
Coveo.SearchProvider.Licensing.LicenseManager.GetLicenseInformation() +57
Coveo.SearchProvider.Applications.Shell.Controls.ConfigureCoveoCloudOrganizationWizardFormPage.ReadFormValues() +483
Coveo.SearchProvider.Applications.Shell.Controls.ConfigurationFileUpdaterWizardFormPage`1.ActivePageChangingToNextPage() +108
Coveo.SearchProvider.Applications.Shell.Controls.CoveoWizardForm.ActivePageChanging(String p_CurrentPageId, String& p_NextPageId) +215
Sitecore.Web.UI.Pages.WizardForm.set_Active(String value) +106
Sitecore.Web.UI.HtmlControls.Button.DoClick(Message message) +60
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +221
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +231
Sitecore.Reflection.ReflectionUtil.InvokeMethod(MethodInfo method, Object[] parameters, Object obj) +89
Sitecore.Web.UI.HtmlControls.Component.HandleMessage(Message message) +195
Sitecore.Shell.Framework.Commands.ClientEventCommand.SendEventMessage() +130
Sitecore.Shell.Framework.Commands.ClientEventCommand.Execute(CommandContext context) +16
Sitecore.Web.UI.Sheer.ClientPage.RaiseEvent() +78
Sitecore.Web.UI.Sheer.ClientPage.OnPreRender(EventArgs e) +801
System.Web.UI.Control.PreRenderRecursiveInternal() +200
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7479
Seem to be a known issue on Coveo, does it help? Or could be similar as well.
If none above helps - download iLSpy to see how/where license is looked for.

Sitecore 6.6 to 7.0 upgrade

Upgrading from sitecore 6.6.0 (rev. 130529) to 7 and all worked fine until I tried to access 'Content Editor'. I get this strange error and have no idea what need to be done.
Exception: System.Web.HttpUnhandledException
Message: Exception of type 'System.Web.HttpUnhandledException' was thrown.
Source: System.Web
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.sitecore_shell_applications_content_manager_default_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\953a4a3d\d5c79dc4\App_Web_l41k3wf4.2.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Nested Exception
Exception: System.Reflection.TargetInvocationException
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Sitecore.Reflection.ReflectionUtil.CallMethod(Type type, Object obj, String methodName, Boolean includeNonPublic, Boolean includeInherited, Boolean includeStatic, Object[] parameters)
at Sitecore.Shell.Applications.ContentManager.ContentEditorPage.OnPreRender(EventArgs e)
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Nested Exception
Exception: System.TypeLoadException
Message: Access is denied: 'Sitecore.Shell.Applications.ContentEditor.RenderingDatasource'.
Source: mscorlib
at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type)
at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Sitecore.Web.UI.XmlControls.ControlSource.ResolveType(String controlName, Assembly assembly)
at Sitecore.Web.UI.XmlControls.AssemblyControlSource.ResolveType(String controlName, Boolean includeDynamicTypes)
at Sitecore.Web.UI.XmlControls.ControlSource.GetControlType(String namespacePrefix, String controlName, String mode, Boolean includeDynamicTypes)
at Sitecore.Web.UI.XmlControls.ControlFactory.GetControlType(String controlName, String mode, Boolean includeDynamicTypes)
at Sitecore.Web.UI.XmlControls.ControlFactory.GetControl(Control parent, String controlName, String mode, Object[] properties, AllowGenericControl allowGeneric)
at Sitecore.Shell.Applications.ContentEditor.EditorFormatter.GetEditor(Item fieldType)
at Sitecore.Shell.Applications.ContentEditor.EditorFormatter.RenderField(Control parent, Field field, Item fieldType, Boolean readOnly, String value)
at Sitecore.Shell.Applications.ContentEditor.EditorFormatter.RenderField(Control parent, Field field, Item fieldType, Boolean readOnly)
at Sitecore.Shell.Applications.ContentEditor.EditorFormatter.RenderField(Control parent, Field field, Boolean readOnly)
at Sitecore.Shell.Applications.ContentEditor.EditorFormatter.RenderSection(Section section, Control parent, Boolean readOnly)
at Sitecore.Shell.Applications.ContentEditor.EditorFormatter.RenderSections(Control parent, Sections sections, Boolean readOnly)
at Sitecore.Shell.Applications.ContentEditor.Pipelines.RenderContentEditor.RenderStandardContentEditor.Process(RenderContentEditorArgs args)
at (Object , Object[] )
at Sitecore.Pipelines.PipelineMethod.Invoke(Object[] parameters)
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Pipelines.CorePipeline.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
at Sitecore.Pipelines.CorePipeline.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
at Sitecore.Pipelines.CorePipeline.Run(String pipelineName, PipelineArgs args)
at Sitecore.Shell.Applications.ContentManager.Editor.Render(RenderContentEditorArgs args, Control parent)
at Sitecore.Shell.Applications.ContentManager.Editor.Render(Item item, Item root, Hashtable fieldInfo, Control parent, Boolean showEditor)
at Sitecore.Shell.Applications.ContentManager.ContentEditorForm.RenderEditor(Item item, Item root, Control parent, Boolean showEditor)
at Sitecore.Shell.Applications.ContentManager.ContentEditorForm.UpdateEditor(Item folder, Item root, Boolean showEditor)
at Sitecore.Shell.Applications.ContentManager.ContentEditorForm.Update()
at Sitecore.Shell.Applications.ContentManager.ContentEditorForm.OnPreRendered(EventArgs e)
Tried few times but I cannot see this going away. Anyone else had this before?
Updated with full stack now. I'm not sure if first 2 exceptions has anything to do with this but it might be part of the problem.
The error is from Sitecore trying to load an assembly via reflection and getting a system level access denied on the DLL. You should check that the identity your AppPool runs as has access to the webroot, in particular, the /bin folder and all it's contents.
Go the IIS and select the the site App pool. Then click on the Advance Setting and navigate to the Process Model Section. Change the Identity to NetworkService.
On your website folder, right click and go to properties. Select the Security Tab and add the following user:
Everyone - check all checkboxes to provide full access
Also, make sure that NETWORK SERVICE is present in the list of usernames which all required access:

Sitecore's "Links" button doesn't work because of a null-reference exception

I am trying to see a certain item's linked items. I am doing this on a client's content management server. When I click on Navigate -> Links, nothing happens. I get this error in the JavaScript console:
http://sitename.local/sitecore/shell/default.aspx?xmlcontrol=Gallery.Links&…de-DE&vs=1&db=master&sc_content=master&ShowEditor=1&Ribbon.RenderTabs=true
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
Here's what I see in Sitecore logs:
38424 19:09:30 ERROR Application error.
Exception: System.Web.HttpUnhandledException
Message: Exception of type 'System.Web.HttpUnhandledException' was thrown.
Source: System.Web
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Nested Exception
Exception: System.Reflection.TargetInvocationException
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Sitecore.Reflection.ReflectionUtil.InvokeMethod(MethodInfo method, Object[] parameters, Object obj)
at Sitecore.Web.UI.Sheer.ClientPage.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Nested Exception
Exception: System.ArgumentNullException
Message: Value cannot be null.
Parameter name: ownerItem
Source: Sitecore.Kernel
at Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName)
at Sitecore.Data.Fields.Field..ctor(ID fieldID, Item ownerItem)
at Sitecore.Shell.Applications.ContentManager.Galleries.Links.GalleryLinksForm.GetLinkTooltip(Item reference, ItemLink link)
at Sitecore.Shell.Applications.ContentManager.Galleries.Links.GalleryLinksForm.RenderReferences(StringBuilder result, List`1 references)
at Sitecore.Shell.Applications.ContentManager.Galleries.Links.GalleryLinksForm.OnLoad(EventArgs e)
It looks like the ownerItem argument is null when creating an item field.
This happens for several different items—e.g. templates and sublayouts.
What is causing this issue and how do I fix it?
This issue was registered as a bug in Sitecore and it was fixed in the Sitecore 8.1 update 2 as a part of the fixes merged from 7.2 update 6:
"Includes all relevant fixes from Sitecore 7.2 update-6"
https://dev.sitecore.net/Downloads/Sitecore%20Experience%20Platform/Sitecore%2081/Sitecore%20Experience%20Platform%2081%20Update2/Release%20Notes
"452241: Links dialog fails if cross-database links are present"
https://sdn.sitecore.net/Products/Sitecore%20V5/Sitecore%20CMS%207/ReleaseNotes/ChangeLog.aspx
To fix the issue in Sitecore 8.1 update 1, please install the following patch:
Put the attached Sitecore.Support.452241.dll file into the bin folder of your solution.
Replace the following string in the Website\sitecore\shell\Applications\Content Manager\Galleries\Links\Gallery Links.xml dialog:
<CodeBeside Type="Sitecore.Shell.Applications.ContentManager.Galleries.Links.GalleryLinksForm,Sitecore.Client"/>
with the new one:
<CodeBeside Type="Sitecore.Support.Shell.Applications.ContentManager.Galleries.Links.GalleryLinksForm,Sitecore.Support.452241"/>
Link of the file you can find it here: https://www.dropbox.com/s/l36zqhwjtahl4q2/Sitecore.Support.452241.dll?dl=0

Sitecore NullReferenceException when saving the layout page

I have got a NullReferenceException but when i'm trying to save the Layout page.
I'm using the Email Campaing Manager.
I have built a Layout page (ASPX) which contains several placeholder linked to custom Sub Layout (ASCX)
After adding those Sublayout form via the Email manager ("Add to Here"), I m clicking on the save button and receiving the error message:
[NullReferenceException: Object reference not set to an instance of an object.]
Sitecore.Modules.EmailCampaign.Core.MessageRelationsCorrector.ReplaceItemPaths(LayoutDefinition layout) +164
Sitecore.Modules.EmailCampaign.Core.MessageRelationsCorrector.CorrectItemRelations(WebPageMail message) +236
Sitecore.Modules.EmailCampaign.Pipelines.CorrectMessageRelations.Process(SaveArgs args) +268
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner) +0
System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner) +72
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +251
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +28
Sitecore.Pipelines.Processor.Invoke(PipelineArgs args) +262
Sitecore.Nexus.Pipelines.NexusPipelineApi.Resume(PipelineArgs args, Pipeline pipeline) +225
Sitecore.Pipelines.Pipeline.Resume() +39
Sitecore.Pipelines.Pipeline.DoStart(PipelineArgs args) +115
Sitecore.Pipelines.Pipeline.Start(PipelineArgs args, Boolean atomic) +133
Sitecore.Pipelines.Pipeline.Start(PipelineArgs args) +32
Sitecore.Shell.Applications.WebEdit.Commands.Save.Execute(CommandContext context) +669
Sitecore.Shell.Framework.Dispatcher.Dispatch(Message message, CommandContext context) +62
Sitecore.Shell.Framework.Dispatcher.Dispatch(Message message, Item[] items) +110
Sitecore.Shell.Framework.Dispatcher.Dispatch(Message message, Item item) +78
Sitecore.Shell.Applications.WebEdit.WebEditRibbonForm.HandleMessage(Message message) +429
Sitecore.Shell.Framework.Commands.MessageCommand.Execute(CommandContext context) +447
Sitecore.Web.UI.Sheer.ClientPage.Dispatch(String command) +143
Sitecore.Web.UI.Sheer.ClientPage.RaiseEvent() +108
Sitecore.Web.UI.Sheer.ClientPage.OnPreRender(EventArgs e) +624
Sitecore.Shell.Applications.WebEdit.WebEditRibbon.OnPreRender(EventArgs e) +35
System.Web.UI.Control.PreRenderRecursiveInternal() +103
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496
Do you know what could be the reason ? If not, how can i debug those kind of error?
I believe that this issue is related to a newly registered bug in the ECM module and I suspect it may have been you who put the original ticket in since the time frames match. However, if it wasn't you or in the interest of passing this along to others who may be experiencing this issue, in order to get around this, you'll need to put a ticket in to Sitecore support. There is an initial hotfix that if they find that your issue is the same or related, they can provide you the hotfix.

Elmah throws exception when accessing Context.Request.ServerVariables

I'm using Elmah to log exceptions for my website, everything seems to be all working fine until one day I noticed that the 500 server errors are not being caught properly. I'm using following script to specifically ignore errors from ScriptResource.axd file.
<errorFilter>
<test>
<or>
<and>
<regex binding="FilterSourceType.Name" pattern="mail" />
<jscript>
<expression>
<![CDATA[
// #assembly mscorlib
// #assembly System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// #import System.IO
// #import System.Web
(Context.Request.ServerVariables["URL"].match(/ScriptResource\.axd/i) && BaseException instanceof System.FormatException)
]]>
</expression>
</jscript>
</and>
</or>
</test>
It seems to be working fine when the first error is triggered. However, the next time this error is triggered Elmah stopped filtering and fails to send email. I was able to reproduce this problem locally and here's the source of the problem:
Microsoft.JScript.JScriptException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at System.Web.HttpServerVarsCollection.Get(String name)
at invoker2.Invoke(Object , Object[] )
at Microsoft.JScript.JSMethodInfo.Invoke(Object obj, BindingFlags options, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.JScript.LateBinding.CallOneOfTheMembers(MemberInfo[] members, Object[] arguments, Boolean construct, Object thisob, Binder binder, CultureInfo culture, String[] namedParameters, VsaEngine engine, Boolean& memberCalled)
at Microsoft.JScript.LateBinding.Call(Binder binder, Object[] arguments, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters, Boolean construct, Boolean brackets, VsaEngine engine)
at Microsoft.JScript.LateBinding.Call(Object[] arguments, Boolean construct, Boolean brackets, VsaEngine engine)
at Microsoft.JScript.Call.Evaluate()
--- End of inner exception stack trace ---
at Microsoft.JScript.Block.Evaluate()
at Microsoft.JScript.FunctionObject.CallASTFunc(Object[] args, Object thisob, ScriptObject enclosing_scope, Closure calleeClosure, Binder binder, CultureInfo culture)
at Microsoft.JScript.FunctionObject.Call(Object[] args, Object thisob, ScriptObject enclosing_scope, Closure calleeClosure, Binder binder, CultureInfo culture)
at Microsoft.JScript.Closure.Call(Object[] args, Object thisob, Binder binder, CultureInfo culture)
at Microsoft.JScript.LateBinding.CallValue(Object val, Object[] arguments, Boolean construct, Boolean brackets, VsaEngine engine, Object thisob, Binder binder, CultureInfo culture, String[] namedParameters)
at Microsoft.JScript.LateBinding.CallValue(Object thisob, Object val, Object[] arguments, Boolean construct, Boolean brackets, VsaEngine engine)
at Elmah.Assertions.JScriptAssertion.FullTrustEvaluationStrategy.Eval(Object context) in C:\workspace\v2_psp\Elmah\src\Elmah\Assertions\JScriptAssertion.cs:line 312
What I don't understand is how and why this occurs. I also tried other ServerVariables and so far I found out that HTTPS, HTTP_REFERER will NOT trigger this error when the same exception happen the second time. While URL, SCRIPT_NAME, PATH_INFO, PATH_TRANSLATED WILL trigger this error.
Thoughts?
Okay! After further digging, it seems like you will NOT be able to access any of the DynamicServerVariable from ServerVariables["XXX"] when using Elmah's JScriptAssertion. However, I did found a workaround, seems like these DynamicServerVariable have public properties mapping on the HttpRequest object!!
Therefore, in my case where I'd like to access Context.Request.ServerVariables["URL"], I can replace the code with Context.Request.FilePath, which is how "URL" is mapped to in the HttpRequest object. This way, the JScriptAssertion would not throw exception when the exception is thrown the second time around.
Following are DynamicServerVariable and their properties mapping in HttpRequest.
ServerVariables HttpRequest Property
URL FilePath
SCRIPT_NAME FilePath (Same as URL)
PATH_INFO Path
PATH_TRANSLATED PhysicalPathInternal
QUERY_STRING QueryStringText
AUTH_TYPE if (_context.User != null && _context.User.Identity.IsAuthenticated) Context.User.Identity.AuthenticationType, otherwise String.empy
AUTH_USER if (_context.User != null && _context.User.Identity.IsAuthenticated) Context.User.Identity.Name, otherwise String.empty
REMOTE_USER if (_context.User != null && _context.User.Identity.IsAuthenticated) Context.User.Identity.Name, otherwise String.empty (Same as AUTH_USER)