tags:

views:

900

answers:

2

I have the following .aspx page, and I want to view it in web browsers such as IE or Google Chrome by opening it directly in those browsers:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    </div>
    </form>
</body>
</html>

But somehow the browsers can't render it. In IE, the error is

Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. A name was started with an invalid character. Error processing resource 'file:/

 <%@ Page Language="C#"AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %> -^*

What did I do wrong?

+3  A: 

Remove or comment out the

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>

line as a browser doesn't know what to do with it. This is normally interpreted by iis and not sent to the browser.

Brettski
+1  A: 

It won't actually work properly unless it is "served" by a web server of some sort.

If you are using Visual Studio, fire up the debugger, which by default will open IE, then grab the url from the location bar, and paste that into the browsers you want to check. Elsewise, mount the web site in IIS, and browse it that way.

Just opening the source file in a browser probably won't give you the result you are looking for.

seanb