|
|
Rank: Newbie
Joined: 2/11/2008 Posts: 16
|
This may be very simple but I am missing it.. Cisco has provided me with code that will pull content in from the Cisco Website. They provide ASP, PHP, ASPX, JSP code to do so. The ASPX code is in either C or VB. I have included the ASPX VB code below. How the heck do I get this into umbraco pages? I have edited out the private stuff Code:<% SVShowContent()%> <script runat="server"> ' Do not edit below this line ' --------------------------------------------------------------------------- Public Sub SVShowContent() Try Dim strURLToGet As String = "http://***********" Dim strQuerystring As String = Request.QueryString.ToString() Dim strReturn As String = "" Dim strSVHost As String = "" If strQuerystring.Length > 0 Then strSVHost += System.Web.HttpUtility.UrlEncode("?" + strQuerystring) End If strURLToGet += "?svhost=" + Request.ServerVariables("server_name") + Request.ServerVariables("script_name") + strSVHost Dim reqSVRemote As System.Net.HttpWebRequest Dim resSVRemote As System.Net.HttpWebResponse Dim srSVRemote As System.IO.StreamReader reqSVRemote = System.Net.WebRequest.Create(strURLToGet) resSVRemote = reqSVRemote.GetResponse() srSVRemote = New System.IO.StreamReader(resSVRemote.GetResponseStream()) strReturn = srSVRemote.ReadToEnd
srSVRemote.Close() resSVRemote.Close() Response.Write(strReturn) Catch ex As Exception Response.Write("<!-- SharedVue Output: " + ex.Message + " -->") End Try End Sub ' --------------------------------------------------------------------------- </script>
|
|
 Rank: Addict
Joined: 9/27/2007 Posts: 977 Location: Belgium
|
Create a user control and paste the code in there. Create a macro and refer to the user control you just built. Drop the macro onto your template and enjoy that 'Aha erlebnis' moment. Good luck!
level 1 certified - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 649 Location: Preston, UK
|
beananimal, You need to create a usercontrol macro put the code in their then drop the macro onto your page. See Tim's excellent vid on how to do it
Level 2 certified. If it aint broke dont fix.
|
|
 Rank: Umbracoholic
Joined: 9/8/2006 Posts: 1,698 Location: KY, USA
|
There are a couple ways to handle this. 1. Copy their .aspx file to a new folder on your webserver. Then tell umbraco to ignore it by updating the following line in the web.config. Of course, this is not running "inside" umbraco or any of the umbraco pages on your site... so that may not be a good choice for you, but it will take about 1 minute to get it running which is always a good place to start.... "make it work, then make it work better" as I like to say. Code: <add key="umbracoReservedPaths" value="/umbraco/,/install/,/myNewFolder/"/>
2. Convert the provided code to a .NET usercontrol, copy the .ascx and .dll to your umbraco site (/usercontrols and /bin folders, respectively), create a new macro and select the usercontrol you made and then insert the macro into an umbraco page or template. 3. Convert the VB code to an XSLT equivalent, create a macro and then insert the macro into an umbraco page or template. Since I'm not a .NET guru I'd start with #1 so that I had something working immediately. Then I'd work on #3. From your sample code, it looks like there is some string manipulation and then an http request to a url which shows the output from that url. These are all easily done in XSLT. You'd probably want to use these function: umbraco.library:GetXmlDocumentByUrl(string) umbraco.library:RequestServerVariables(string) umbraco.library:RequestQueryString(string) umbraco.library:RequestForm(string) concat() cheers, doug.
MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
|
|
Rank: Newbie
Joined: 2/11/2008 Posts: 16
|
Thank you for the replies...
drobar, that is kind of what I was going to do if all else failed... Just create a static page and link to it.
I will look into the usercontrol method as I am new to XSLT programming and I am not sure I am ready for the headache... I am a fluent VB programmer, but am struggling with some of the XPATH/UMBRACO/XSL functionality.
They (CISCO) also provide an iFrame method and I got that to work. I just don't want to use the iFrame because google will not index the contents (from what I understand).
Thanks for all the help (everyone)... i will keep you informed.
|
|
 Rank: Umbracoholic
Joined: 7/20/2006 Posts: 1,074 Location: Charleston, West Virginia, United States
|
The XSLT method may not work well, as their code would have to be properly marked-up xml to load into the xslt through GetDocumentByUrl. This method is intended to pull XML documents from remote sites, and allow traversal in xslt. While it is possible with standard page content, it would have to be well marked up. Thus, the user control method is probably the simplest. Also, use the caching features here to improve performance. You may want to set it to 5 minutes or more.
• 2007/2008 MVP • 2008/2009 MVP • Certified • Licensing • Support • Development • Hosting •
|
|
Rank: Newbie
Joined: 2/11/2008 Posts: 16
|
I am working on the usercontrol method now.
As this is all somewhat new to me.. (I am a VB6/ASP guy). First I tried just pasting the code into an ascx file and linking that to a macro. I guess it is not that easy :)
I suppose I have to put the code into vb.net and create a DLL. That is fine if I don't have to change anything. If I do, then I guess I will have to learn. I have had very little exposure to the .NET side of things. I have done a few small vb.net apps, but they were more along the lines of windows forms projects.
|
|
 Rank: Umbracoholic
Joined: 9/8/2006 Posts: 1,698 Location: KY, USA
|
Casey is right that for GetXmlDocumentByUrl() expects to get a well-formed page in response. xhtml would be fine. HTML might or might not be well-formed (probably not). Since you've got background in programming think you're right to look into making a user control... it will be more robust. Check out Tim's excellent screencast at http://www.nibble.be/?p=12 to see how easy it is to make and use a custom .net usercontrol in umbraco. cheers, doug.
MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
|
|
Rank: Newbie
Joined: 2/11/2008 Posts: 16
|
I have tried to get this to work using VS 2008 Express and VWD 2008 Express. Neither have the ability to compile the code into a DLL. If the code is simply put into an ASCX file it causes no errors in umbraco but the content is not rendered in the page. I have considered installing the VS.NET 2003 package but am not sure if that will help me or not. I am about to pull my hair out. Is anybody that is more versed in "user web control" creating willing to take the Cisco Supplied code and create the proper .ascx and .dll for me? The iFrame and it's scrollbars are just not acceptable to render this content. I hate to ask for somebody to do something that should be simple, but I have struggled with this for two days and don't see that "ohh wow" moment anywhere on the horizon. I fear I have ignored .NET for far too long and many of the basics have passed me by. I have posted the full code as provided from cisco. (after looking at it, it appears that the content is pulled from the cisco website based on the URL of the webserver. There is nothing secret about the URL. It just returns web code based on what server asks for it. Code:<% SVShowContent()%> <script runat="server"> ' Do not edit below this line ' --------------------------------------------------------------------------- Public Sub SVShowContent() Try Dim strURLToGet As String = "http://cisco.sharedvue.net/sharedvue/pull/" Dim strQuerystring As String = Request.QueryString.ToString() Dim strReturn As String = "" Dim strSVHost As String = "" If strQuerystring.Length > 0 Then strSVHost += System.Web.HttpUtility.UrlEncode("?" + strQuerystring) End If strURLToGet += "?svhost=" + Request.ServerVariables("server_name") + Request.ServerVariables("script_name") + strSVHost Dim reqSVRemote As System.Net.HttpWebRequest Dim resSVRemote As System.Net.HttpWebResponse Dim srSVRemote As System.IO.StreamReader reqSVRemote = System.Net.WebRequest.Create(strURLToGet) resSVRemote = reqSVRemote.GetResponse() srSVRemote = New System.IO.StreamReader(resSVRemote.GetResponseStream()) strReturn = srSVRemote.ReadToEnd
srSVRemote.Close() resSVRemote.Close() Response.Write(strReturn) Catch ex As Exception Response.Write("<!-- SharedVue Output: " + ex.Message + " -->") End Try End Sub ' --------------------------------------------------------------------------- </script>
|
|
 Rank: Umbracoholic
Joined: 9/8/2006 Posts: 1,698 Location: KY, USA
|
For a fun little exercise I decided to convert this to a C# user control. I followed the steps shown in Tim's screencast, referenced above, for creating the project in Visual Studio, copying the dll and ascx files to my umbraco site, creating a macro and inserting the macro into a page. Here's the code behind for the dll (SharedVue.ascx.cs) Code:using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Net; using System.IO;
namespace SharedVue { public partial class SharedVue : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { try { string strURLToGet = "http://cisco.sharedvue.net/sharedvue/pull/"; string strQuerystring = Request.QueryString.ToString(); string strReturn = ""; string strSVHost = "";
if (strQuerystring.Length > 0) strSVHost += System.Web.HttpUtility.UrlEncode("?" + strQuerystring);
strURLToGet += "?svhost=" + Request.ServerVariables["server_name"].ToString() + Request.ServerVariables["script_name"].ToString() + strSVHost;
HttpWebRequest reqSVRemote = (HttpWebRequest)HttpWebRequest.Create(strURLToGet); HttpWebResponse resSVRemote = (HttpWebResponse)reqSVRemote.GetResponse(); StreamReader srSVRemote = new StreamReader(resSVRemote.GetResponseStream()); strReturn = srSVRemote.ReadToEnd();
srSVRemote.Close(); resSVRemote.Close();
litSharedVue.Text = strReturn.ToString(); } catch (Exception ex) { Response.Write("<!-- SharedVue Output: " + ex.Message + " -->"); }
} } }
Here's the code for the user control (SharedVue.ascx) Code:<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SharedVue.ascx.cs" Inherits="SharedVue.SharedVue" %> <asp:Literal ID="litSharedVue" runat="server" />
I've emailed the project and files to you. Let us know how it works out. cheers, doug.
MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
|
|
Rank: Newbie
Joined: 2/11/2008 Posts: 16
|
Thank you for taking the time to work on this.
I have added the dll file to the BIN folder and the ascx file to the usercontrol folder.
I created the macro and selected the proper usercontrol. I then added the macro to my template between the ASP form tags (as directed). Sadly, the content is not rendered in the browser :( There are no errors returned.
I am inclined to bet that your code is fine and either I have done something wrong or this content is not compatible with the the umbraco structure. I would think that the control would work on your site and return generic Cisco content instead of the customized content that I pay for.
Were you able to see content returned when you tested the control? If so, then I feel rather silly at this point.
You can go directly to the URL that is supplied in the script, you will see the generic cisco content that is pushed back.
Again, I can't thank you enough for taking the time to help me.
Bill
|
|
 Rank: Umbracoholic
Joined: 9/8/2006 Posts: 1,698 Location: KY, USA
|
Hey, Bill, Umbraco can certainly get and display the output, that's not going to be a problem. I do get content back, but it shows that I'm not signed up for their service. I assume that if the calling URL is from a site registered with them that full content would be returned and displayed. The strURLToGet variable that gets requested from my site is: http://cisco.sharedvue.net/sharedvue/pull/?svhost=www.percipientstudios.com/default.aspx?umbPage=/bar/foobar.aspxIf you follow the link you'll get an empty page in your browser. But if you look at the source code of that page you'll see the following: This is the same output I get when I look at the source of the webpage on my umbraco site that has the macro in it. So at least on my site the code is working and would display content if Cisco sent me any. You should get at least some output from the macro, even if it is just an alert message such as I received. cheers, doug.
MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
|
|
Rank: Newbie
Joined: 2/11/2008 Posts: 16
|
I never thought to look at the page source for the rendered page! Looking at my page, I also get But the iFrame works from this site. So I guess I need to figure out why the URL is not being authenticated through the Cisco interface. If I can not figure it out this afternoon, I will get Cisco on the phone Monday. How did you see the actual strURLTOGet string being passed to the Cisco site? I feel so out of my element! ASP and ADO/DAO was so much easier for me!
|
|
Rank: Newbie
Joined: 2/11/2008 Posts: 16
|
Okay.... I just moved the www host header in IIS to the umbraco site. The content is now being rendered. The Cisco verification must only work for domain.tld and www.domain.tld It appears to choke on any host other than 'www' Thanks again! In the meantime I have figured out how to use getmedia() to mange the header images on each page :) I sure am not thrilled with the xslt stuff.
|
|
 Rank: Umbracoholic
Joined: 9/8/2006 Posts: 1,698 Location: KY, USA
|
You're welcome. Glad it's working. You can probably talk to Cisco about your registration if you need to use a different domain than www.domain.tld. Congratulations on using GetMedia() and XSLT working. You're not alone in finding XSLT a love-hate relationship. It is blisteringly fast (love) but extremely verbose and tedious (hate). But since the world is moving to XML in almost every area it is a great skill to develop. cheers, doug.
MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
|
|
Rank: Newbie
Joined: 2/11/2008 Posts: 16
|
the page will be live for a few hours while I get the CSS worked out for the content container and sidebar. It will then go back down so that I can finish the rest of the site (a LOT) to do. Most everything is just placeholders now and some content pulled from the old horrible website. I have built the site from the basic website package. It has been a help in learning about the different umbraco elements. I am now comfortable with templates, document types, data types and somewhat the xslt and macros. I have been able to add tabs and properties to pages for menu placement and levels, etc. I have not posted here much, but a lot of lurking has helped me. Sadly, most of the links in old posts are broken due to the new site, as well as many of the google links. I would imagine google will get much of it re-indexed over time. You can view the results of your work here: http://www.mbtechnology.net/solutions/cisco-smb-solutions.aspx
|
|
 Rank: Umbracoholic
Joined: 9/8/2006 Posts: 1,698 Location: KY, USA
|
Now that you've started posting I hope you'll continue. Not only asking questions but increasingly answering those you can. Congrats on getting the site so far. It looks like you're well on your way. Yes, the links to the old forum are a bother. Sometimes you can search on the post title if it is part of the link. But those links that just point to an id number... those are hard. cheers, doug.
MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
|
|
|
Guest |