Jun 2, 2009

System.Security.SecurityException: Requested registry access is not allowed. when writing to event log

I got this error when I try to create an eventlog source and when I try to write to the new event log (after resorting to manually creating the event log source) with my ASP.NET application.
See the end of this post for the full error message and stack trace.
This seems to be a very commom problem - and not consistent either. My guess is that it's due to the tightening of security recently, ie XP SP2. Use of the Network Service account (on win2k3) or AD accounts can help.
To resolve you need to give the ASP.NET user permission to read from the event log registry entries. And here's how:
1. Select Start - Run, then enter: regedt32
2. Navigate/expand to the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Security
3. Right click on this entry and select Permissions
4. Add the ASPNET user
5. Give it Read permission

Error : ASP.NET Webservices: "The request failed with HTTP status 401: Access Denied." Error

We can resolve this issue by either of the following ways:
1. Enabling Anonymous Access in the IIS Directory Security
To do this, the following steps will help you.
1. Click "Start" - "Run" - Type "inetmgr" and press "Ok" or "Enter" Key
2. IIS Control panel opens.
3. Expand the appropriate nodes and navigate to the virtual directory of your Web Service Application.
4. Select the Virtual directory, Right Click and select "Properties"
5. Switch to the "Directory Security" Tab and then Click "Edit".
6. Check the "Anonymous Access" CheckBox.
7. Click "Ok" twice to exit.

This should solve the issue

Jun 1, 2009

Get IP Address of a HOST in VB.NET

The .Net DNS class can be used to get a host name or an IP of a given host name. To use DNS class in your project, you need to include System.Net.

Include System.Net Reference.

And say I want to get IP address if http://www.google.com
The given code will do that for you.

Imports System
Imports System.Net
Namespace DNSName
'


' Summary description for Class1.
'
Class Class1
'Entry point which delegates to C-style main Private Function
Public Overloads Shared Sub Main()
Main(System.Environment.GetCommandLineArgs())
End Sub
Overloads
Shared Sub Main(args() As String)
Dim ipEntry As IPHostEntry = Dns.GetHostByName(http://www.google.com/)
Dim IpAddr As IPAddress() = ipEntry.AddressList
Dim i As Integer
For
i = 0 To IpAddr.Length - 1
Console.WriteLine("IP Address {0}: {1} ", i, IpAddr(i).ToString())
Next i
End Sub 'Main
End Class 'Class1
End Namespace 'DNSName

Error: Unable to Start Debugging on the Web Server

When you try to debug an application (ASP.Net 2) running on a Web server, you may sometimes get this error message:
Unable to start debugging on the Web server

If your message is longer than that, it is covered by a subtopic of this one.

1- Review the procedures for setting up ASP.NET or ATL Server. For more information see Getting Ready to Debug ASP.NET Applications.

2- Do you have the necessary access privileges for debugging? For more information see the Security Requirements section in

3- checking SSL (Security Socket layer) & Trying to open website again without SSL.

4- From a command prompt window, run the following command: systemroot\Microsoft.NET\Framework\ versionNumber \aspnet_regiis -i


Our Reference :

http://msdn.microsoft.com/en-us/library/dwesw3ee(VS.80).aspx