How do i create a menu item to point away from my site?

Topics: Developer Forum, Project Management Forum, User Forum
Apr 21, 2008 at 8:25 AM
As far as I can tell if you put something like http://AnotherSite.com in the virtual page link box it will BREAK the application. (I've already had someone try this and had to go into the web site to fix it by modify some of the APPData or APPCode code ( I can't remeber off the top of my head right now).

Anyways has anyone else encountered this and figured out how to get around it?
Apr 24, 2008 at 7:02 PM
I think this a wrong approach to try to add a non SiteMapNode. Why won't you use a linklist or extend a new section to do that.
One of our customers insisted to do that http://www.galacticassault.com/ .The forum link goes outside to thier website. So adding a outgoing link shouldn't b a problem. The problem comes later in sitemap.axd when Google tries to get the nodes.
Apr 25, 2008 at 1:53 AM
Edited Apr 25, 2008 at 2:02 AM


rickardmagnusson wrote:
I think this a wrong approach to try to add a non SiteMapNode. Why won't you use a linklist or extend a new section to do that.
One of our customers insisted to do that http://www.galacticassault.com/ .The forum link goes outside to thier website. So adding a outgoing link shouldn't b a problem. The problem comes later in sitemap.axd when Google tries to get the nodes.


OK I logged into GalacticAssault.com and had a look around the admin pages to see if they were any different than mine. Other than I am using the latest beta and GA seems to be something else as it is 1.4.0 and I thought mine was 1.2.0?

I do see in the Navigation.aspx page that the Forum does indeed point to an outside URL. When I add mine I get the following error.



Server Error in '/' Application.
--------------------------------------------------------------------------------

'~/http://new.ravenainternational.com.aspx' is not a valid virtual path.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: '~/http://new.ravenainternational.com.aspx' is not a valid virtual path.

Source Error:


Line 23: protected override void Render(System.Web.UI.HtmlTextWriter writer)
Line 24: {
Line 25: base.Render(new RewriteFormHtmlTextWriter(writer));
Line 26: }
Line 27: }


Source File: c:\inetpub\vhosts\ravenainternational.com\subdomains\french\httpdocs\App_Code\Form.cs Line: 25

Stack Trace:


HttpException (0x80004005): '~/http://new.ravenainternational.com.aspx' is not a valid virtual path.
System.Web.Util.UrlPath.CheckValidVirtualPath(String path) +746587
System.Web.Util.UrlPath.Combine(String appPath, String basepath, String relative) +155
System.Web.UI.Control.ResolveClientUrl(String relativeUrl) +196
System.Web.UI.WebControls.MenuItem.RenderItem(HtmlTextWriter writer, Int32 position, Boolean enabled, Orientation orientation, Boolean staticOnly) +1867
System.Web.UI.WebControls.Menu.RenderContents(HtmlTextWriter writer, Boolean staticOnly) +2583
System.Web.UI.WebControls.Menu.Render(HtmlTextWriter writer) +225
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +130
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +24
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +130
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +24
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +7
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +29
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +130
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +24
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +59
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +68
System.Web.UI.Adapters.ControlAdapter.Render(HtmlTextWriter writer) +18
MyWebPagesStarterKit.FormRewriterControlAdapter.Render(HtmlTextWriter writer) in c:\inetpub\vhosts\ravenainternational.com\subdomains\french\httpdocs\App_Code\Form.cs:25
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +2067937
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +37
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +130
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +24
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +29
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +130
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +24
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +130
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +24
System.Web.UI.Page.Render(HtmlTextWriter writer) +26
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1896




--------------------------------------------------------------------------------
Version Information

For whatever reason mine wants to add a `/ to the front of anything it finds in the Virtual Path textbox.

If you add the URL correctly and hit save it adds it automatically.

I had to go into the App_Data/Web.sitemap file and remove the tilden and forward slash from in front of http:// to get it to work.

The reason I wanted to do this was I have a main international site and on its home page a handful of flags that will point to different websites at different sub domains. I wanted to put and the bottom of the menu a link directly back to the main web site.

it really isn't that big a deal as I can have all of the sites interlink with the flags, (use the same linking system as the main site on all subs)
Apr 25, 2008 at 7:29 AM
I now remeber that I did do a change in the save of pages.
Do not copy this directly into your cms. Just make the modifications that's required.
See line below with stars

protected void btnSave_Click(object sender, EventArgs e)
{
Validate();
if (IsValid)
{
WebPage page = new WebPage(lstPages.SelectedValue);

page.Title = txtTitle.Text.Trim();
page.NavigationName = txtNavigation.Text.Trim();
page.Visible = chkVisible.Checked;
page.VisibleInMenu = ChkVisibleInMenu.Checked;
page.AllowAnonymousAccess = chkAnonymousAccess.Checked;

string virtualPath = txtVirtualPath.Text.Trim().ToLower();

if(!virtualPath.StartsWith("http")) //*******************************Does no modification if it's an outgoing url*******************************************************
{
if (virtualPath != string.Empty)
{
if (!virtualPath.StartsWith("~/"))
{
if (virtualPath.StartsWith("/"))
virtualPath = virtualPath.Substring(1);
virtualPath = "~/" + virtualPath;
}
if ( !virtualPath.EndsWith(".aspx") && !virtualPath.EndsWith("/") )
{
virtualPath += ".aspx";
}
else if (virtualPath.EndsWith("/"))
{
virtualPath = "~/";
}
virtualPath = virtualPath.Replace(' ', '-');
}
}

page.VirtualPath = virtualPath;
txtVirtualPath.Text = virtualPath;
page.SeoDescription = txtSeoDescription.Text;
page.SaveData();

if (editor == null)
editor = new SitemapEditor();
editor.UpdatePage(page);
editor.Save();

Response.Redirect(string.Format("{0}?sel={1}", Request.Url.AbsolutePath, lstPages.SelectedValue));
}
}
Apr 25, 2008 at 2:37 PM


rickardmagnusson wrote:
I now remeber that I did do a change in the save of pages.
Do not copy this directly into your cms. Just make the modifications that's required.
See line below with stars ..................................


Great Thanks, I think I will add the line to all of my sites and directly to my starting Zip file. It will protect against anyone accidently bring down their site by trying to add an outside link. I already had one customer do it. I guess the other way is to validate the input to not contain http:// or www. Would I have to add

if(!virtualPath.StartsWith("www"))

To prevent a site entry like www.anothersite.com from breaking it too? I haven't tried to break it this way yet.

Can you elaborate on this statement

" The problem comes later in sitemap.axd when Google tries to get the nodes. "

Thank you

Fred
Apr 27, 2008 at 9:10 PM


tinwistle wrote:


rickardmagnusson wrote:
I now remeber that I did do a change in the save of pages.
Do not copy this directly into your cms. Just make the modifications that's required.
See line below with stars ..................................


Great Thanks, I think I will add the line to all of my sites and directly to my starting Zip file. It will protect against anyone accidently bring down their site by trying to add an outside link. I already had one customer do it. I guess the other way is to validate the input to not contain http:// or www. Would I have to add

if(!virtualPath.StartsWith("www"))

To prevent a site entry like www.anothersite.com from breaking it too? I haven't tried to break it this way yet.

Can you elaborate on this statement

" The problem comes later in sitemap.axd when Google tries to get the nodes. "

Thank you

Fred


If you are planning to let Google's sitemaptool to add a "Googlesitemap", then Google requires unique links from your site and complains if there are any outgoing links..
Aug 6, 2008 at 4:14 PM

Thanks!!!

This worked great!  The hardest part I had was finding the appropriate .comfig file, but the rest was easy.

Sep 16, 2008 at 3:02 PM
rickardmagnusson,

Where exactly (file path & name) does one make the modifications to incorporate this feature? Also, does this simply prevents the breaking of a site or actually allows adding menu navigation to external sites? I want to implement the later.
Sep 20, 2008 at 1:32 PM
Im with you MrJazze, where do i fix this code? can someone please step a newbie thru the process. Please.

thanks!