Thursday, February 9, 2012

New IIS 7 Site not working and no error messages

I ran into a problem where I was setting up a new web site on an existing IIS 7 server and couldn't get the site to return anything to the browser. Not even an error message!
The new site used a new ip address and port which appeared fine in Windows 2008 and in IIS Manager.

I removed the site and added it back several times. Tried everything I could think of to the App Pools but couldn't even get an event to be logged in the event viewer.

When the site was added to IIS, it first showed the error:

“Unknown: The object identifier does not represent a valid object. (Exception from HRESULT: 0x800710D8)”

This didn’t help much as it went away when you refresh IIS Manager.

The site just flat out didn’t work. Here is what I did:

1. Verify the service is running and listening on a port

(At the command prompt)
TELNET 192.168.1.16 8080
GET /

If this returns HTML then a web server was listening on the new IP address and port. This however didn’t return anything, which meant there was a problem.

2. Look at Windows Task Manager for a w3wp.exe process running under the account that the new App Pool was setup to run under. App Pools will display in Task Manager this way—but not in this case, which means that a call to the server couldn’t reach iis to spawn a new process.
3. This has all the makings of a firewall problem, but there was no firewall running (I disabled to troubleshoot this)

Solution

4. Next I found a tip on google to use netsh to setup the ip address to be used by iis

C:\netsh

netsh>http
netsh http>sho iplisten

IP addresses present in the IP listen list:
-------------------------------------------

192.168.1.27

netsh http>add iplisten ipaddress=192.168.1.16

IP address successfully added

netsh http>sho iplisten

IP addresses present in the IP listen list:
-------------------------------------------

192.168.1.27
192.168.1.16

netsh http>

Problem solved!

Thursday, December 4, 2008

ASP.NET Convert a Relative URL to an Absolute URL

My ASP.NET web application needed to send a notification e-mail to a user that included a dynamically generated link. To create this link, I wanted to pass a relative url including the tilde i.e ("~/DirectoryA/Webform.aspx?querystring=1") and have an absolute url returned ("http://www.domain.com/DirectoryA/Webform.aspx?querystring=1")

So I wrote this:

public string ResolveAbsoluteUrl(string url)
{
// Get the site root
string rawURL = Request.Url.ToString();

// Find the end of the root
int rootEnd = rawURL.IndexOf('/', rawURL.IndexOf("//") + 2);
if (rootEnd < 0) { rootEnd = rawURL.Length; }

// Combine the root with the resolved url
string rootURL = rawURL.Substring(0, rootEnd);

return string.Format("{0}{1}", rootURL, ResolveUrl(url));
}

Thursday, November 13, 2008

Operation could destabilize the runtime.

Problem:
I had an ASP.NET web application that worked fine in development, but on the test server threw the error:

Operation could destabilize the runtime.

Solution:

After attempting a myriad of solutions that other people used to resolve their problems, I decided to look a little deeper into my code and found the following:

if (credentials == null)
{
if (!IsDomainUser)
{
// throw access error
throw new System.Security.VerificationException();

Basically, I was throwing this error myself. The vagueness of the error didn't help, but in my own defense, I was trying to share libraries between a web application and a desktop application, and well... code that should ownly be called on a desktop or server application won't always fun so well in a web application.

Wednesday, November 5, 2008

Where's the ADO Entity Framework?

So I'm using Visual Studio 2008 and install the .NET 3.5 Framework SP1 and I do not have an option use the Entity Framework Model designer or any of the associated types. "What's up?" I think!

So I look around on google and can't find anything. So, I finally figured it out and I'm going to share. So here goes:

YOU HAVE TO INSTALL THE VS2008 SP1 that comes with the .NET 3.5 Framework SP1 to get that stuff!!!

And there you have it!

Thank you ladies and gentlemen.

Monday, November 3, 2008

Installing .NET Framework 3.5 SP 1


"Disconnect from the internet!" Are you crazy!

Saturday, November 1, 2008

Copying items to the clipboard in VS 2005 caused snippets to appear in the Toolbox

Problem:

When I would copy code to the clipboard while in Visual Studio 2005 and 2008, the text that copied would appear as a snippet in the Toolbox. The Toolbox would eventually fill-up.


Solution:

Delete local Toolbox files and the problem goes away.


Thanks to the poster NoiseMaker at http://forums.asp.net/p/993239/1339348.aspx, I was able to get past this problem. In his entry, he deleted the following files:

C:\Documents and Settings\MyUser\Local Settings\Application Data\Microsoft\VisualStudio\8.0\toolbox.tbd
C:\Documents and Settings\MyUser\Local Settings\Application Data\Microsoft\VisualStudio\8.0\toolbox_reset.tbd
C:\Documents and Settings\MyUser\Local Settings\Application Data\Microsoft\VisualStudio\8.0\toolboxIndex.tbd
C:\Documents and Settings\MyUser\Local Settings\Application Data\Microsoft\VisualStudio\8.0\toolboxIndex_reset.tbd


My files were in a different place because I'm on Vista, but the solution still worked for me. Btw, my (tbd) files were in the following location:

C:\Users\jaclimer.CXP\AppData\Local\Microsoft\VisualStudio\8.0\toolbox.tbd

A socket operation was attempted to an unreachable host

Problem:

After joining a newly loaded domain, I received the following error when trying to use Remote Desktop: "A socket operation was attempted to an unreachable host"


Cause:

After playing around I found that my routing entries did not have a gateway added. This was because I had recently loaded a Windows Server 2003 Domain Controller and had just setup DHCP.


Solution:

Add a gateway.


I did it manually, though I wouldn't recommend it. In this case, I was loading a temporary network on a 192.168.3.x network where my router was 192.168.3.1 and my domain controller was 192.168.3.5.

When I ran (from the command prompt) : c:\route print

I noticed no line existed for 0.0.0.0 (no gateway). So I added the router as a gateway as follows:

c:\route add 0.0.0.0 mask 0.0.0.0 192.168.3.1

This is, however, a temporary route and will be removed when the machine reboots. I could have used the '-P' flag to make it permanent, but in this case, this was all temporary.

I should add, that I also got an error TFS Error TF50621 which also had to do with me messing around with the domain controller.

The problem was that I started with one IP Address, 192.168.1.X and setup the domain controller. Then I changed the IP to 192.168.3.X and I got the error mentioned above.

The fix was to go in to the Domain Controller, goto DHCP settings, and add 192.168.3.x to the Reverse Lookup Zones.