Thursday, December 18, 2008

WTF: ASP.NET Tracing

What The F*ck!

Using the Microsoft.VisualBasic.Logging.FileLogTraceListener for tracing within my (C#) ASP.NET website only succeeds if a folder 'C:\Documents and Settings\Default User\Application Data\Microsoft Corporation\Internet Information Services\6.0.3790.1830' is present (read: on my webserver). For some reason the specified path, wherever it comes from (?), is used as a temporary location, even if the actual location is configured to be elsewhere.

Eg.:

<listeners>
<add name="MyTraceListener"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Location="Custom"
CustomLocation="c:\temp"
LogFileCreationSchedule="Daily"
BaseFileName="ArtImageProcessorJob"
traceOutputOptions="DateTime"
/>
</listeners>

Tuesday, August 19, 2008

A Word a Day: URL slug

A URL slug is a SEO- and user-friendly string-part in a URL to identify, describe and access a resource. Often the title of a page/article is a valid candidate.

The slug in the URL of this post (http://codemansion.blogspot.com/2008/08/word-day-url-slug.html) is 'word-day-url-slug'
(not that friendly, as it is autogenerated by Blogger).

Friday, June 20, 2008

UnitTesting an ASP.NET Web Application Project

Having a solution named 'UnitTestingASPNETwebApp'
, with an ASP.NET Web Application Project named 'MyWebApplication'
and a Test Project with name 'MyWebApplication.UnitTests'
, U can test the 'Page_Load' method of a webform 'Default.aspx'
using 1 of following testmethods


[TestMethod()]
[HostType("ASP.NET")]
[AspNetDevelopmentServerHost("UnitTestingASPNETwebApp\\MyWebApplication", "/")]
[UrlToTest("http://localhost:3798/Default.aspx")]
[DeploymentItem("MyWebApplication.dll")]
public void Page_Load__OnChangeTitle_Succeed()
{
_Default_Accessor target = new _Default_Accessor();
target.Page_Load(null, EventArgs.Empty);
Page p1 = target.Target as Page;
Assert.AreEqual(p1.Title, "My Home Page");
}


[TestMethod()]
[HostType("ASP.NET")]
[AspNetDevelopmentServerHost("UnitTestingASPNETwebApp\\MyWebApplication", "/")]
[UrlToTest("http://localhost:3798/Default.aspx")]
[DeploymentItem("MyWebApplication.dll")]
public void Page_Load__OnChangeTitle2_Succeed()
{
Page p2 = this.TestContext.RequestedPage;
PrivateObject po = new PrivateObject(p2);
po.Invoke("Page_Load", p2, EventArgs.Empty);
Assert.AreEqual(this.TestContext.RequestedPage.Title
   , "My Home Page"
   );
}



Default.aspx's codebehind class '_Default' looks like

public partial class _Default : Page
{
protected void Page_Load(Object sender, EventArgs e)
{
this.Title = "My Home Page";
}
}

Friday, May 16, 2008

10 Years, 5 Months and 15 Days

... of accident-free driving-experience ...
But this morning, faith turned.
That back seat door of my first 18 years old car will never open again ...

Some would see a sign in that other car's owner's cellphone-number ending with 666.

Friday, April 25, 2008

(Last) ConfigurationSectionHander using LINQ to XML

Craig Andera's last ConfigurationSectionHandler revised
, using LINQ to XML.

public class XElementConfigurationSectionHandler :
    IConfigurationSectionHandler
{
public XElementConfigurationSectionHandler() {}

public Object Create(Object parent
    , Object configContext
    , XmlNode section)
{
    XElement xel;

    using (XmlNodeReader r = new XmlNodeReader(section))
    {
        xel.Load(r);
    }

    return xel;
}
}