XslTransform in .NET v1.1

4 views
Skip to first unread message

George Durzi

unread,
Nov 13, 2003, 12:58:28 PM11/13/03
to
I know this has changed greatly since v1.0. I'm converting a small portion
of my application where I do a transformation.
The error happens on this line:
oXslTransform.Load(XslPath + DataSourceName + ".xsl", oXmlUrlResolver);
ex.Message gives me: "Invalid Site"
ex.InnerException is empty

I've verified that XslPath + DataSourceName + ".xsl" is giving me the
correct path to the stylesheet in the format:

\\servername\e$\XslPath\StylesheetName.xsl

Here's my code

string ReportPath = ReportsFilePath + DataSourceName + TimePeriodSuffix
+ PreferredEmailFormat;
// Create a FileStream to write with
System.IO.FileStream oFileStream = new System.IO.FileStream(ReportPath,
System.IO.FileMode.Create);
// Create an XmlTextWriter for the FileStream
System.Xml.XmlTextWriter oXmlTextWriter = new
System.Xml.XmlTextWriter(oFileStream, System.Text.Encoding.Unicode);

try
{
// Create an XmlDataDocument from the ReportData DataSet parameter
XmlDataDocument oXmlDataDocument = new XmlDataDocument(ReportData);

// Set up the transformation
System.Xml.Xsl.XslTransform oXslTransform = new
System.Xml.Xsl.XslTransform();

// Load the Xsl and Transform
XmlUrlResolver oXmlUrlResolver = new XmlUrlResolver();
oXmlUrlResolver.Credentials = CredentialCache.DefaultCredentials;
oXslTransform.Load(XslPath + DataSourceName + ".xsl", oXmlUrlResolver);
// Xsl Path is class variable
oXslTransform.Transform(oXmlDataDocument, null, oXmlTextWriter,
oXmlUrlResolver);

// Close the XmlTextWriter object
oXmlTextWriter.Close();

return ReportPath;
}
catch (System.Exception ex)
{
oXmlTextWriter.Close();
System.IO.File.Delete(ReportPath);
throw (ex);
}


George Durzi

unread,
Nov 13, 2003, 5:59:00 PM11/13/03
to
There must be some sort of rights issue. The code below works perfectly when
my Xsl is on a local drive, for example e:\Xsl\MyStyleSheet.Xsl

I get the "Invalid Site" error when my stylesheet is being referenced as
\\server\e$\Xsl\MyStyleSheet.Xsl

"George Durzi" <gdu...@hotmail.com> wrote in message
news:eRps8#gqDHA...@tk2msftngp13.phx.gbl...

Oliver

unread,
Nov 13, 2003, 6:34:41 PM11/13/03
to
It sounds like the UNC share doesn't know or recognize the ASPNET account or
whoever it is impersonating. You might want to check the permissions on the
share.


"George Durzi" <gdu...@hotmail.com> wrote in message

news:u9dK7mjq...@TK2MSFTNGP10.phx.gbl...

George Durzi

unread,
Nov 13, 2003, 6:46:07 PM11/13/03
to
The ASPNET account has full control of the whole virtual directory and I am
still experiencing this error :(

Back to square one.

"Oliver" <DEATHTOSPA...@hotmail.com> wrote in message
news:OZ20v6jq...@tk2msftngp13.phx.gbl...

Oliver

unread,
Nov 13, 2003, 7:22:00 PM11/13/03
to
But is ASP.NET impersonating someone who doesn't have rights... like the
IUSR_<machinename> account?


"George Durzi" <gdu...@hotmail.com> wrote in message

news:%237TvPBk...@TK2MSFTNGP11.phx.gbl...

George Durzi

unread,
Nov 13, 2003, 7:56:38 PM11/13/03
to
This is actually a Console application. Would Console applications also run
as the ASPNET account?


"Oliver" <DEATHTOSPA...@hotmail.com> wrote in message

news:OUMIMVkq...@TK2MSFTNGP10.phx.gbl...

Oliver

unread,
Nov 13, 2003, 10:33:30 PM11/13/03
to
Hi George,

I think a console application would run as the logged on user unless
configured to run as someone else.


"George Durzi" <gdu...@hotmail.com> wrote in message

news:%23slfook...@TK2MSFTNGP09.phx.gbl...

George Durzi

unread,
Nov 14, 2003, 1:00:03 AM11/14/03
to
I'm running the Console app on my machine in debug mode logged on with my
user id which is an enterprise admin on our domain.

When I point to my test Xsls locally on my machine (they're accessible at
e:\inetpub\wwwroot\MyApp\Xsl) everything runs fine. But when I switch to my
production Xsls accessible at \\server\e$\inetpub\etc ... I get that error.

I'll play around with it a little more tomorrow having it run under
different Ids. I'll post my success/failure here.

Amazing how this damn XmlResolver has turned 1 line of code into 5

"Oliver" <DEATHTOSPA...@hotmail.com> wrote in message

news:eIN8MAmq...@TK2MSFTNGP11.phx.gbl...

Bret Mulvey [MS]

unread,
Nov 14, 2003, 10:34:57 AM11/14/03
to
.NET 1.1 changed how XslTransform handles security. If I understand the docs
correctly, .NET 1.0 ran XSLT's (scripts embedded in XSLT's, access from
document() Xpath function, etc.) in a fully-trusted way. .NET 1.1 restricts
the level of trust by default. Remote files are less trusted than local
files, so you may be getting a security error because of that.

If you trust the remote XSLT, you give XsltTransform the same level of trust
as the calling assembly by passing this.GetType().Assembly.Evidence to the
evidence parameter of the Load method.

"Oliver" <DEATHTOSPA...@hotmail.com> wrote in message

news:eIN8MAmq...@TK2MSFTNGP11.phx.gbl...

George Durzi

unread,
Nov 14, 2003, 1:11:30 PM11/14/03
to
Bret and Oliver
Thank you both for your help. I've gotten this to work.

"Bret Mulvey [MS]" <br...@online.microsoft.com> wrote in message
news:BC6tb.1329$Dw6.12720@attbi_s02...

Oliver

unread,
Nov 14, 2003, 6:29:09 PM11/14/03
to
Good to hear that George. What was it?


"George Durzi" <gdu...@hotmail.com> wrote in message

news:OSJ07qtq...@TK2MSFTNGP09.phx.gbl...

Gerald

unread,
Dec 2, 2005, 8:29:20 PM12/2/05
to
So, George, What's the SOLUTION!????

From http://www.developmentnow.com/g/8_2003_11_0_0_165508/XslTransform-in--NET-v1-1.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com

Reply all
Reply to author
Forward
0 new messages