Hi,
this is really a beginner question:
when I start debuging an ASP.net projet in VS, IE opens up to display the Default.aspx webpage and the following URL is in the adress bar: http://localhost:52480/Default.aspx. My page including C# codebehind controllers works fine. If I stop debbuging and I try to double click on Default.aspx from the Windows explorer then IE opens up but gives me and XML error message for line 1 column 2 of my Default.aspx witch is the first line where I declare the laguage used for code behing, AutoEventWireup and so on. So I wonder why can't I open an aspx page by just double clicking on the icon. I also copied all the project folder to \wwwroot (iss) and I tried to open the same page on a second PC (on the same LAN) specifying the IP adress of my server. Now the page commes up but when I click on a controller (a button for instance) I recieve a Run Time Error from IE. Can some help me understand what is the diffrence of opening a aspx page while debbuging and trying to open it by double clicking on the icon. I also want to be able to get the page to work from the client PC.

Thanks

Dani AI

Generated

Quick clarification for (building on points from and ):

Opening an .aspx file by double‑clicking simply hands the raw file to your browser — there is no ASP.NET processing, so server directives and code‑behind are left unexecuted (that is why IE shows a parse/XML error). When you run from Visual Studio the page is served by an ASP.NET‑capable server and the browser receives the final HTML; to make the page work for other machines you must host it on a web server that runs ASP.NET.

Do not remove the <%@ Page %> directive or the DOCTYPE to “fix” the parse error — that only hides the symptom and prevents your server code from running. Instead deploy properly. Practical checklist to get the page working from a client PC:

  1. Publish the site from Visual Studio (File -> Publish or Build -> Publish Web Site) to a folder on the server. For Web Application projects this produces a DLL in the site’s bin folder; for Web Site projects ASP.NET can compile on first request but publishing is still recommended.
  2. In IIS Manager create a Website or convert the folder to an Application and assign an Application Pool that matches your target .NET CLR.
  3. Ensure the app pool identity has read/execute access to the site folder and that firewall rules allow the HTTP port.
  4. Access using an HTTP URL from the client (for example: ).

If you still see runtime errors from the client, diagnose with these steps: temporarily enable detailed errors in web.config (only while debugging):

<system.web>
  <compilation debug="true" />
  <customErrors mode="Off" />
</system.web>

Also check IIS logs (C:\inetpub\logs\LogFiles) and the Windows Event Viewer. Common causes are a missing/incorrect bin assembly, wrong .NET version on the app pool, the folder not configured as an IIS Application, or file/permission issues. Finally, revert debug to false and customErrors to On before exposing the site publicly.

Recommended Answers

All 2 Replies

The purpose of an Aspx page is to run at application server, and not to be viewed using browser.

Reason you are getting error on opening the aspx file on browser is because the browser finds that the Aspx does not confirm to regular XML standards.

1. You can remove the Page directive( line begining with <%@ )
2. You can remove the DOCTYPE declaration.

http://www.javascriptkit.com/howto/doctype.shtml

Now your aspx should look like plain XML ( between <html> tags) , which you can view on the browser.

The aspx is run at server and an is HTML generated which is showed on an browser when you open through VS.

And when you open it directly from a browser, it is considered as plain XML.

Thanks,
Chithra

When you run the default.aspx from VS, actually the page is running in a built-in web server of VS 2005/2008 called cassini wev server so that you are able to view in IE.

But if you try to open the .aspx directy from IE through Windows Explorer, the .aspx file will be treated as an xml file and IE will try to parse it.

You can view the .aspx pages from your PC or other PC from network only after deploy your application in IIS.

A simple way to deploy your asp.net application in IIS in Windows XP is right click on the folder in Windows Explorer->Properties->Web Sharing->Share this folder->Enter Alias Name->Press Ok.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.