when I create folder for every page and remap those in web.config , appeared this problem .
1)I can't see content of pages.
2)When I use navigation controls , my web.SiteMap don't work and don't show path of pages.
what is problem in my project , and what I solve that ?
this link is my web site :
Urlmapping code :
<urlMappings>
<add url ="~/HOME" mappedUrl ="~/Default.aspx"/>
<add url ="~/a" mappedUrl ="~/a.aspx" />
<add url ="~/a1" mappedUrl ="~/a1/a1.aspx"/>
<add url ="~/a2" mappedUrl ="~/a2/a2.aspx"/>
<add url ="~/b" mappedUrl ="~/b/b.aspx"/>
<add url ="~/b1" mappedUrl ="~/b1/b1.aspx"/>
<add url ="~/b2" mappedUrl ="~/b2/b2.aspx"/>
<add url ="~/b3" mappedUrl ="~/b3/b3.aspx"/>
<add url ="~/c" mappedUrl ="~/c/c.aspx"/>
<add url ="~/c1" mappedUrl ="~/c1/c1.aspx"/>
</urlMappings>
SiteMap code :
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/HOME" title="Home" description="Home Page">
<siteMapNode url="~/a" title="page a" description="page a">
<siteMapNode url="~/a1" title="page a-1" description="page 1 of a" />
<siteMapNode url="~/a2" title="page a-2" description="page 2 of a"/>
</siteMapNode>
<siteMapNode url="~/b" title="page b" description="page b">
<siteMapNode url="~/b1" title="page b-1" description="page 1 of b" imageTitle="lake"/>
<siteMapNode url="~/b2" title="page b-2" description="page 2 of b" imageTitle="wolf"/>
<siteMapNode url="~/b3" title="page b-3" description="page 3 of b" imageTitle="thunder"/>
</siteMapNode>
<siteMapNode url="~/c" title="page c" description="page c">
<siteMapNode url="~/c1" title="page c-1" description="page 1 of c"/>
</siteMapNode>
</siteMapNode>
The problem is that the Url your are wanting is a actual folder in your wbesite so IIS picks this up first. There are acouple of ways to get around this.
Change all the .aspx filenames to be Default.aspx and these will be picked when you type http://website/a for example if you have a folder called "a" with Default.aspx in it, remove all the entries in the urlMappings
Have the URL as a different name to a actual directory
Use ASP.Net URL Routing that has been introduced in 3.5 SP1 look at Chis Cavanagh blog post on it.
Use as Jose mentioned the ReWritter
I can solve my problem .
you should create folder whit name Default and create page whit name default too and then use web.sitemap in navigation controls .
Related
I am new to Asp.net and I had some trouble with menu navigation.
I had the Web.sitemap
<siteMapNode url="~/" title="Home" description="Home">
<siteMapNode url="~/Default" title="Home" description="Go to the homepage" />
<siteMapNode url="~/Reviews/Default" title="Reviews" description="Reviews published on this site">
<siteMapNode url="~/Reviews/AllByGenre" title="By Genre" description="All Reviews Grouped by Genre" />
<siteMapNode url="~/Reviews/All" title="All Reviews" description="All Reviews" />
</siteMapNode>
<siteMapNode url="~/About/Default" title="About" description="About this Site">
<siteMapNode url="~/About/Contact" title="Contact Us" description="Contact Us" />
<siteMapNode url="~/About/AboutUs" title="About Us" description="About Us" />
</siteMapNode>
<siteMapNode url="~/Login" title="Login" description="Log in to this web site" />
and the start page Default.aspx gives
But it just gives HTTP Error 404.0 not found errorwhen I try to navigate. URL is http://localhost:24186/About/AboutUs
url ="~/About/Default" . Try add the .aspx like
url="~/About/Default.aspx"
I am not sure though. Cant see issue otherwise. I normally add the .aspx and i think it should be there.
So, here's what I'm working on. I have an ASP.NET web app, in which the sitemap is displayed on the site.master file through the web.sitemap.
Here's the site.master:
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
<asp:TreeView
ID="TreeView1"
runat="server"
ataSourceID="SiteMapDataSource1"
ExpandDepth="1">
</asp:TreeView>
And here's the web.sitemap:
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/Default.aspx" title="Home" description="Home">
<siteMapNode url="" title="Projects" description="">
</siteMapNode>
<siteMapNode url="" title="Configurations" description="Configurations">
<siteMapNode url="" title="Experiments" description="Experiments">
</siteMapNode>
<siteMapNode url="" title="Cell Line" description =""></siteMapNode>
<siteMapNode url ="" title ="Drugs">
</siteMapNode>
<siteMapNode url ="" title="Manage Configurations" />
<siteMapNode url="~/ExperimentConfigurationView.aspx" title ="Configure Experiements"/>
<siteMapNode url="~/DrugConfigurationView.aspx" title="Configure Drugs"/>
</siteMapNode>
</siteMapNode>
<siteMapNode url="" title="Drug Recipes" description="">
</siteMapNode>
</siteMapNode>
</siteMap>
Now, here's where I'm running into a problem. What I'd like to do is combine this site map with a dynamically created SiteMapProvider, and populate the sub-trees of this map. For example, the Projects, Experiments, Cell Line and Drug Recipe nodes would each have a sub-tree, populated from a datebase. Anyone have input, or a suggestion as to where to start looking?
In summary - I'd like to point the leaf siteMapNodes to a SiteMapProvider.
Solution:
I added a file DrugListProvider.cs in the root directory. That holds the code for dynamically generating the sub-tree.
I placed the following node in the Web.sitemap, where I wanted the sub-tree to appear:
<siteMapNode provider="DrugListProvider"/>
Finally, I include this in the web.config file:
<siteMap>
<providers>
<add name="DrugListProvider" type="PrivoWeb.DrugListProvider"/>
</providers>
</siteMap>
These Site Map Node is in Web.Config
<siteMapNode title="Hotel Setup" roles="Administrator,Hotel Admin">
<siteMapNode url="~/Page/HotelSetup/RoomTypeManagement.aspx" title="Room Types" />
<siteMapNode url="~/Page/HotelSetup/AddOns/AddOnCategoryProperties.aspx" title="Add On Categories" />
<siteMapNode url="~/Page/HotelSetup/AddOn.aspx" title="Add Ons" />
<siteMapNode url="~/Page/HotelSetup/Package.aspx" title="Packages" />
<siteMapNode url="~/Page/PriceTools/Promotion.aspx" title="Promotions" />
<siteMapNode url="~/Page/PriceTools/PromotionAddOn.aspx" title="AddOns Incentive" />
<siteMapNode url="~/Page/SupportAdmin/TranslationProperty.aspx" title="Translations" />
</siteMapNode>
Is there anyway to made some sub sitemapnode in hotel setup can be accessed only by administrator but not hotel admin ?
Problem solved, it need to be set in location path
I have routing set up as follows:
void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("", "Home", "~/Default.aspx");
......
}
I'm implementing breadcrumbs using a SiteMapPath control:
<asp:SiteMapPath ID="SiteMapPath1" CssClass="breadCrumbs" runat="server">
</asp:SiteMapPath>
Web.sitemap is set up as follows:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="Home" title="Home" description="Home">
<siteMapNode url="~/About" title="About" description="About">
<siteMapNode url="~/History" title="History"
description="History" />
</siteMapNode>
</siteMapNode>
</siteMap>
My problem is that when I navigate to mysite.com instead of mysite.com/default.aspx, the Home breadcrumb node does not appear. What am I missing?
UPDATE
I managed to get the "Home" node to display by updating Web.sitemap as follows:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="Home" title="Home" description="Home">
<siteMapNode url="~/Default.aspx" title="" description="" />
<siteMapNode url="~/About" title="About" description="About">
<siteMapNode url="~/History" title="History"
description="History" />
</siteMapNode>
</siteMapNode>
</siteMap>
The only remaining problem is that the path separator is still displaying on home page for mysite.com
Is there a way to programatically render the separator invisible for the home page? The SiteMapPath control itself is in a master page.
Maybe you should change your sitemap file as follows :
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/" title="Global Site Name or Welcome Message" description="Home">
<siteMapNode url="~/Home" title="Home" description="" />
<siteMapNode url="~/About" title="About" description="About">
<siteMapNode url="~/History" title="History"
description="History" />
</siteMapNode>
</siteMapNode>
</siteMap>
and from the sitemapdatasource you should set ShowStartingNode="false" and I think that this solves both of your problems at once...
NOTE: of course this will require that you made this change in the global.asax file (VB):
RouteTable.Routes.MapPageRoute("Home0", "", "~/Default.aspx", True)
RouteTable.Routes.MapPageRoute("Home1", "Home", "~/Default.aspx", True)
hope this helps...
I have sitemap which looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/default.aspx" title="Prva stran" roles="*" description="Shema ISEF">
<siteMapNode roles="2" title="Analize" id="Analize" description="" >
<siteMapNode url="~/karneki1.aspx" title="Karneki1" description="" />
<siteMapNode url="~/karneki2.aspx" title="Karneki2" description="" />
</siteMapNode>
</siteMapNode>
</siteMap>
if I set roles in a siteMapNode with title "Analiza" it works fine, the link is not shown in the navigation... but if I set roles on any of "karneki" siteMapNode the links are still visible...
Is it even posible to restrict access to lower links based on user role?
Use the SiteMap 'securityTrimmingEnabled' attribute:
http://msdn.microsoft.com/en-us/library/ms178428.aspx
The asecurityTrimmingEnabled attribute also needs to be added to the nodes in the markup:
http://weblogs.asp.net/jgalloway/archive/2008/01/26/asp-net-menu-and-sitemap-security-trimming-plus-a-trick-for-when-your-menu-and-security-don-t-match-up.aspx
An overview of how securityTrimmingEnabled is supposed to work:
http://blogs.msdn.com/b/dannychen/archive/2006/03/16/553005.aspx
The solution to this is that you need to set the roles in a Web.config for the pages itself.
See http://weblogs.asp.net/jgalloway/archive/2008/01/26/asp-net-menu-and-sitemap-security-trimming-plus-a-trick-for-when-your-menu-and-security-don-t-match-up.aspx
e.g. in the folder for a page called AdminOnly.aspx add a Web.Config with the following:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="AdminOnly.aspx">
<system.web>
<authorization>
<allow roles="Administrator"/>
<deny users="*" />
</authorization>
</system.web>
</location>
</configuration>
Try to add the roles to the site map like this
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/default.aspx" roles="*" title="Prva stran" roles="*" description="Shema ISEF">
<siteMapNode roles="2" title="Analize" id="Analize" description="" >
<siteMapNode roles="*" url="~/karneki1.aspx" title="Karneki1" description="" />
<siteMapNode roles="*" url="~/karneki2.aspx" title="Karneki2" description="" />
</siteMapNode>
</siteMapNode>
</siteMap>