Sunday, March 27, 2011

Customize the Default Web Page for a ClickOnce Application

Sander, has wrote a related article for this...

http://todotnet.com/archive/2005/10/11/2595.aspx

unfortunately the code is in C#.

Which is the equivelant to the vb.net version?

From stackoverflow
  • Converted with http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Imports System.Net
    Imports System.Xml.Xsl  
    Imports System.Net
    
    Dim request As HttpWebRequest = DirectCast(HttpWebRequest.Create("...url to the original publish.htm file..."), HttpWebRequest)
    Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
    Dim dataStream As Stream = response.GetResponseStream()
    Dim reader As New StreamReader(dataStream)
    Dim responseFromServer As String = reader.ReadToEnd()
    
    responseFromServer = responseFromServer.Replace(" ", " ")
    
    Dim xml As New System.Xml.XmlDocument()
    xml.LoadXml(responseFromServer)
    
    Dim xslt As New XslCompiledTransform()
    Dim html As TextWriter = New StringWriter()
    xslt.Load(Server.MapPath("CustomPublish.xsl"))
    xslt.Transform(xml, Nothing, html)
    
    Response.Write(html.ToString())
    Response.[End]()
    

    Let me know if it works.

  • curly lines are shown in...

    HttpWebRequest 'type is not defined'

    HttpWebResponse 'type is not defined'

    whatknott : Either fully qualify the names (System.Net.HttpWebRequest) or import the System.Net namespace.
  • Imports System.IO
    Imports System.Xml.Xsl
    Imports System.Net
    
    Dim request As HttpWebRequest = DirectCast(Net.WebRequest.Create("http://www.myurl"), HttpWebRequest)
    Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
    Dim dataStream As Stream = response.GetResponseStream()
    Dim reader As New StreamReader(dataStream)
    Dim responseFromServer As String = reader.ReadToEnd()
    responseFromServer = responseFromServer.Replace(" ", " ")
    Dim xml As New System.Xml.XmlDocument()
    xml.LoadXml(responseFromServer)
    Dim xslt As New XslCompiledTransform()
    Dim html As TextWriter = New StringWriter()
    xslt.Load(Server.MapPath("CustomPublish.xsl"))
    xslt.Transform(xml, Nothing, html)
    response.Write(html.ToString())
    response.End()
    

    ...one line before end i get, "write is not a member of system.net.httpwebresponse"

    ...and in the last line i get "end is not a member of system.net.httpwebresponse"

    Thank you for your time

  • Response.Write(html.ToString())
    

    Capitalize.

    Please comment answers and check best answer, so we can keep in touch.

  • after capitalizing the situation got better but now i get the error

    The '=' character, hexadecimal value 0x3D, cannot be included in a name

    in the line xml.LoadXml(responseFromServer)

    any further ideas? I am stackoverflow with this one!

0 comments:

Post a Comment