how to setup Elmah for asp.net 1.1? - asp.net

I am trying to setup elmah for asp.net 1.1 application.
i have following entry in my web.config
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
</httpModules>
<configSections>
<sectionGroup name="elmah">
<section name="security" type="Elmah.SecuritySectionHandler, Elmah"/>
<section name="errorLog" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" type="Elmah.ErrorFilterSectionHandler, Elmah"/>
</sectionGroup>
did i missing anything?

We need to log error into XML files and it should be available from remote location. my web.config looks
<configSections>
<sectionGroup name="elmah">
<section name="security" type="Elmah.SecuritySectionHandler, Elmah"/>
<section name="errorLog" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" type="Elmah.ErrorFilterSectionHandler, Elmah"/>
</sectionGroup>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
</httpModules>
<!--
<elmah>
<security allowRemoteAccess="yes" />
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="C:\Inetpub\wwwroot\LearnElmah\App_Data\Elmah" />
</elmah>
-->
<!-- DYNAMIC DEBUG COMPILATION
Set compilation debug="true" to enable ASPX debugging. Otherwise, setting this value to
false will improve runtime performance of this application.
Set compilation debug="true" to insert debugging symbols (.pdb information)
into the compiled page. Because this creates a larger file that executes
more slowly, you should set this value to true only when debugging and to
false at all other times. For more information, refer to the documentation about
debugging ASP.NET files.
-->
<compilation
defaultLanguage="c#"
debug="true"
/>
<!-- CUSTOM ERROR MESSAGES
Set customErrors mode="On" or "RemoteOnly" to enable custom error messages, "Off" to disable.
Add <error> tags for each of the errors you want to handle.
"On" Always display custom (friendly) messages.
"Off" Always display detailed ASP.NET error information.
"RemoteOnly" Display custom (friendly) messages only to users not running
on the local Web server. This setting is recommended for security purposes, so
that you do not display application detail information to remote clients.
-->
<customErrors
mode="Off"
/>
<!-- AUTHENTICATION
This section sets the authentication policies of the application. Possible modes are "Windows",
"Forms", "Passport" and "None"
"None" No authentication is performed.
"Windows" IIS performs authentication (Basic, Digest, or Integrated Windows) according to
its settings for the application. Anonymous access must be disabled in IIS.
"Forms" You provide a custom form (Web page) for users to enter their credentials, and then
you authenticate them in your application. A user credential token is stored in a cookie.
"Passport" Authentication is performed via a centralized authentication service provided
by Microsoft that offers a single logon and core profile services for member sites.
-->
<authentication mode="Windows" />
<!-- AUTHORIZATION
This section sets the authorization policies of the application. You can allow or deny access
to application resources by user or role. Wildcards: "*" mean everyone, "?" means anonymous
(unauthenticated) users.
-->
<authorization>
<allow users="*" /> <!-- Allow all users -->
<!-- <allow users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
<deny users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
-->
</authorization>
<!-- APPLICATION-LEVEL TRACE LOGGING
Application-level tracing enables trace log output for every page within an application.
Set trace enabled="true" to enable application trace logging. If pageOutput="true", the
trace information will be displayed at the bottom of each page. Otherwise, you can view the
application trace log by browsing the "trace.axd" page from your web application
root.
-->
<trace
enabled="false"
requestLimit="10"
pageOutput="false"
traceMode="SortByTime"
localOnly="true"
/>
<!-- SESSION STATE SETTINGS
By default ASP.NET uses cookies to identify which requests belong to a particular session.
If cookies are not available, a session can be tracked by adding a session identifier to the URL.
To disable cookies, set sessionState cookieless="true".
-->
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>
<!-- GLOBALIZATION
This section sets the globalization settings of the application.
-->
<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
/>

You also need the elmah section that defines the type of logger you are going to use, and, depending on which logger you use, possibly a connectionstring :
<elmah>
<security allowRemoteAccess="yes" />
<!--<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/Elmah" />-->
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="elmah" applicationName="MyApp" />
</elmah>
<connectionStrings>
<add name="elmah" connectionString="" providerName="System.Data.SqlClient" />
</connectionStrings>

this is a very late entry but anyone trying to set up ELMAH with .NET 1.1 and Visual Studio 2003, browse to following location:
https://code.google.com/p/elmah/source/browse/samples/web.config?repo=1x&r=c1d14a9e1626b74a4a606bae8bf9ae829ec641c5

Related

Accessing ACS Token and claim rules not working

Edit: I found the solution, look at the end.
I have an ASP.NET Web Role for Azure that I'm currently running with the emulator. I modified the default implementation so that I can use Google and Live ID as Identity Providers. I used the Identity & Access Extension to adapt my Web.Config file.
The problem is that when i access the claims via User as ClaimsPrincipal then I see only the claims from the Identity Provider (e.g. Google). The rule group for my relying party program (defined in ACS Portal) doesn't even have a passthrough rule associated but still i get those claims. On the other side I added a Claim Rule to change the name claim type provided by Google to a custom output value but from code behind I only see the value that comes from Google.
My Question:
What do I need to do to be able to issue a token from the issuer (STS) based on the claims of the Identity Provider and how do I access this token from Code?
I'm using:
Visual Studio 2012
.NET Framework 4.5
Parts of my Web.config:
<system.web>
<authentication mode="None" />
<httpRuntime targetFramework="4.5" requestValidationMode="4.5" />
...
</system.web>
...
<appSettings>
<add key="ida:FederationMetadataLocation" value="https://mynamespace.accesscontrol.windows.net/FederationMetadata/2007-06/FederationMetadata.xml" />
<add key="ida:Issuer" value="https://mynamespace.accesscontrol.windows.net/v2/wsfederation" />
<add key="ida:ProviderSelection" value="ACS" />
</appSettings>
<system.webServer>
<modules>
<remove name="FormsAuthentication" />
<add name="WSFederationAuthenticationModule" type="System.IdentityModel.Services.WSFederationAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=bla" preCondition="managedHandler" />
<add name="SessionAuthenticationModule" type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=bla" preCondition="managedHandler" />
</modules>
</system.webServer>
<system.identityModel>
<identityConfiguration>
<audienceUris>
<add value="http://127.0.0.1:7777/" />
</audienceUris>
<issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=bla">
<trustedIssuers>
<add thumbprint="myRelyingPartyThumbprint(from ACS Portal)" name="https://mynamespace.accesscontrol.windows.net/" />
</trustedIssuers>
</issuerNameRegistry>
<certificateValidation certificateValidationMode="None" />
</identityConfiguration>
</system.identityModel>
<system.identityModel.services>
<federationConfiguration>
<cookieHandler requireSsl="false" />
<wsFederation passiveRedirectEnabled="true" issuer="https://mynamespace.accesscontrol.windows.net/v2/wsfederation" realm="http://127.0.0.1:7777/" requireHttps="false" />
</federationConfiguration>
The url that is used to redirect users to login page is: "https://mynamespace.accesscontrol.windows.net:443/v2/wsfederation?wa=wsignin1.0&wtrealm=http%3a%2f%2f127.0.0.1%3a7777%2f"
My test rule lools like this:
Solution: The problem was that I had "http://localhost:7777/" as realm in the ACS but I specified 127.0.0.1 at the Identity & Access tool. When my program requested the ACS in order to choose an Identity Provider a relying party named WebRole11 was automatically created for 127.0.0.1 including pass-through rules. So my custom rules weren't applied because the automatically created Relying Party Application Settings were used instead of mine.

Elmah and Sitecore and 404 error processing

Hello I am trying to setup ELMAH with Sitecore, I have read this http://newguid.net/sitecore/2011/using-elmah-for-error-logging-within-sitecore/#t-recent and it solution is working fine with some error from my point of view.
1. ELMAH skip store 404 to store in log in all cases +
2. Sitecore not processing 404 error in case if URL contain "." char. For example http://mysite/wrongurl redirect me to 404.html but http://mysite/wrongurl.dfgd show to me Server Error in Application (IIS 7.5)(not my 404.html)
this is my settings just releted to ELMAH and processing errors
<configSections>
<sectionGroup name="elmah">
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah"/>
</sectionGroup>
</configSections>
<elmah>
<!-- NetKeyElmah inside of App_Config\ConnectionStrings.config -->
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ElmahData" />
</elmah>
<sitecore>
<settings>
<setting name="ItemNotFoundUrl" value="/404.html" />
<setting name="LayoutNotFoundUrl" value="/404.html" />
<setting name="LinkItemNotFoundUrl" value="/sitecore/service/notfound.aspx" />
<setting name="IgnoreUrlPrefixes" value="/sitecore/admin/elmah.axd|/sitecore/default.aspx" />
</settings>
</sitecore>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
</modules>
<handlers>
<add name="Elmah" path="/sitecore/admin/elmah.axd" verb="POST,GET,HEAD" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
</handlers>
</system.webServer>
<system.web>
<customErrors mode="On" defaultRedirect="/errorpage.html" >
<error statusCode="404" redirect="/404.html" />
<error statusCode="500" redirect="/500.html" />
</customErrors>
</system.web>
How to setup finish my setup in correct way.
In response to 2.
By default, IIS will not process every type of file. If you want IIS or Sitecore to process a given file type that it doesnt recognize you need to specify that in the web.config. Update the following two sections in your web.config to include the file types that you want Sitecore to process:
<param desc="Allowed extensions (comma separated)">aspx, ashx, asmx, asp</param>
and
<param desc="Allowed extensions (comma separated)">aspx,asp</param>
In these sections you would add the file extensions that are currently throwing errors and this will make Sitecore process your file type.

Requests against elmah.axd always fails with a 500 - Internal server error. Why? :-(

I used the NuPack tool to add Elmah to a site on my developer machine. This worked like a charm, but when I send a request to the elmah.axd page all I get in return is 500 - Internal server error.
My code setup:
Visual Studio 2010
Site built on top of EPiServer 4.62B
Running on .NET Framework 2 (because of EPiServer)
My IIS setup:
IIS 7.5
Classic .NET AppPool (because of EPiServer)
My computer:
running Windows 7 32bit (because of EPiServer)
ELMAH content in web.config:
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
inside configSections.
<elmah>
<security allowRemoteAccess="yes" />
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
</elmah>
At this stage I don't really need allowRemoteAccess since I am running everyting from my machine, but trying anything at the moment. And I know elmah.dll is running because the log files are beeing created.
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
inside system.web | httpHandlers.
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
inside system.web | httpmodules.
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
inside system.webServer | modules
<add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
inside system.webServer | handlers
I have basically added every suggestion I could find on the net to the web.config, but without it doing any good. Which leads me to believe that something else is wrong, any ideas?
You dont have a connection string to the Elmah database in there.
Also have you added the Elmah and SqlLite dlls to your bin folder?
I have a minimal setup guide here which might help:
http://www.codeulike.com/2010/05/quick-elmah-setup.html
I'm having this problem too. The only thing I've found that works is to switch my application pool to integrated mode. My app hasn't been fully tested against this though, so I haven't change this in production.
There is a possibility that the elmah_error DB table needs repair.
It happened in my case a couple of times and by repairing, it was fixed.
I had the exact same problem elmah-> 500 - Internal Server Error.
just run mysql command:
repair table elmah.elmah_error;
and retry to access elmah.

What to do if Elmah can't reach the database to log an exception?

OK, apparently related questions dont seem to address this directly. An exception reaches Elmah, maybe a repository cant reach a database, but then neither can Elmah reach that database. Even if they target different servers, maybe its a network problem.
Is there a way to configure fallback logs for Elmah for cases like this, e.g. a text file, message queue, email, sms, etc? If so, where do I start looking to do this, excpt for now the Elmah source code.
I am usually not so concerned about that: If the DB is not running then my application is not running and I have no exceptions to log anyway. But if this is an issue for you then you could consider to use the XmlFileErrorLog.
As far as I can tell you cannot use more then one log destination and there is nothing like a fallback. You could however configure email notifications, but then you would get all exceptions by email as well.
Here is quite a nice article about elmah.
I released a composite errorlog which address exactly this issue.
You can install it via Nuget or copy it from sources into your projects.
Basic usage from config file :
<configuration>
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.FallbackErrorLogSectionHandler, Elmah.FallbackErrorLog" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
</configSections>
<elmah>
<errorLog type="Elmah.FallbackErrorLog, Elmah.FallbackErrorLog" >
<add type="Elmah.SqlErrorLog, Elmah" connectionStringName="DB_ELMAH" applicationName="Blog" />
<add type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/Logs" />
<add type="Elmah.MemoryErrorLog, Elmah" size="30" />
</errorLog>
</elmah>
</configuration>

ELMAH: ASP.NET security

I have an ASP.NET 3.5 application which is using the Visual Studio Development Server. I set ELMAH up, and it is working fine. I set up the AXD "file" and XML files (using XML as the storage medium) to be in a folder under the root:
v3/elmah/
Now, I'd like to have it so that when elmah or elmah/elmah.axd (or anything in this directory) is requested, that a username/password dialog is presented. Right now, I have this in the web.config:
Which is allowing all authenticated users, I believe. I've tried to disable anonymous access to that directory, but the file is still being served. Is there something I need to change in the Security of the file system?
BTW, this is XP SP3.
Thanks all!
Did you add something like this to your web.config?
<location path="admin/elmah.axd">
<system.web>
<authorization>
<allow roles="Admin"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
There is also a requirePermission attribute available for the ELMAH section nodes in the web.config.
<sectionGroup name="elmah">
<section name="security" requirePermission="true" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="true" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="true" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="true" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
Update to avoid a mess in the comments:
In my web.config I use something like:
<authentication mode="Forms">
<forms loginUrl="Users/SignIn"
timeout="30"
.. moreStuffHere />
</authentication>

Resources