asp.net 2.0 - aspx file to return xml?

  • Thread starter Thread starter Sergei Shelukhin
  • Start date Start date
S

Sergei Shelukhin

Hi. The question may be stupid, but when I try ti produce asp file that
outputs xml the way I did it in 1.1 - by emptying the aspx file itself
or adding something like
<?xml version="1.0" encoding="utf-8" ?>
<test><%=phrase%></test>
in there, I get XHTML validation errors and my web site refuses to
build.

How do I fix this?
 
Do you use web application project or something that forces you to build
"for real" in VS2005? See, with default web site model, "Build" you do in VS
is actually just a deep validation check (it also notes XHTML validation
errors), which yes errors in VS, but it doesn't prevent you from running the
page at all ASP.NEt environment is the one doing the compilation, VS doesn't
actually do it. (VS2005 Web Application project, WAP, is a different beast
as it works similarly as things worked in VS2003).

Just open the page in browser from the server.
 
I did, it says BC30451: Name 'phrase' is not declared., as if the page
wasn't built (phrase is defined as public string and the value is set)
 
I would try emptying the ASPX page portion of everything except the @Page
declaration.

Then in your Page_Load in your codebehind,
Response.ContentType="text/xml";
Response.Write (your xml string here);

Peter
 
Oh. It was actually the @Page declaration that i accidently removed
that was causing the errors; it works now

Thanks :)
 
Back
Top