Reading an embedded file from an ASP.NET Custom Server Control an rendering it

Posted by Andreas Grech on Stack Overflow See other posts from Stack Overflow or by Andreas Grech
Published on 2010-03-31T17:02:40Z Indexed on 2010/03/31 17:03 UTC
Read the original article Hit count: 222

I currently have a file "abc.htm" in my Custom Server Control Project and it's Build Action is set to Embedded Resource.

Now in the RenderContents(HtmlTextWriter output) method, I need to read that file and render it on the website.

I am trying the following but it's to no avail:

protected override void RenderContents(HtmlTextWriter output)
{
    var providersURL = Page.ClientScript.GetWebResourceUrl(typeof (OpenIDSel), "OpenIDSelector.Providers.htm");
    var fi = new FileInfo(providersURL); // <- exception here

    //the remaining code is to possibly render the file
}

This is an example of how the providersURL is:

/WebResource.axd?d=kyU2OiYu6lwshLH4pRUCUmG-pzI4xDC1ii9u032IPWwUzMsFzFHzL3veInwslz8Y0&t=634056587753507131

FileInfo is throwing System.ArgumentException: Illegal characters in path.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about custom-server-controls