Really struggling with this and not finding much helpful stuff on google.
I set up a sitemap, and I want some breadcrumbs such that url:
/CatManagement/Cats/38
displays breadcrumbs
Cat Management > Cats > Mr. Fuzzy Wuzzy
I don't quite understand what the sitemap node structure would be for this as the 38 is sort of a parameter of Cats.
In the dynamicNodeProvider I created I can probably grab the ID somehow and do a quick lookup to get the name, but I am not sure how to bring it all together.
Any ideas?
Have a look at Routing Basics in the MvcSiteMapProvider wiki. You just need to ensure that your parameter (38) is preserved from the current request, the node matching logic already takes into consideration action method parameters. That example shows how you would do that using a custom dynamic node provider, but I recommend reading the entire document as understanding it is key to making MvcSiteMapProvider work.
I have also created a more in depth look at the problem here with working demos for download: http://www.shiningtreasures.com/post/2013/09/02/how-to-make-mvcsitemapprovider-remember-a-user-position
Related
I already set up DocumentDb and uploaded the documents to DocumentDb.
My JSON documents have data nested upto 4 levels, eg:-
{
id: '12345',
properties:
{
Accessories:
{
watch:1,
WristBands: [{
blue:1,
red: 2}]
}
}
Name: Leo,
Age: 24
}
I want to use azure search service for able to search upto the last level(e.g. The count of wristband colour i.e. blue:1). I have setup the service as well.
I want some help in creating the index and the indexer for such nested data in C# so that I can query the service.
Already found, how to use DataType.Collection(DataType.String), but this supports till level 2.
Classes can also be made for each sub-level but have no idea how to define them during indexing. Refered to example https://github.com/Azure-Samples/search-dotnet-getting-started .
One more tutorial on setting up Azure Search indexer for DocumentDB: https://azure.microsoft.com/en-us/documentation/articles/documentdb-search-indexer/.
+1 on Kirk Evans' blog post, which shows how to flatten the JSON document. The idea is to leverage the optional query property under container in the data source creation request, and use a join query in that place.
Unfortunately, Azure Search does not support nested documents. As you can see from our Uservoice page, this by far the most requested feature so it is something that we are very interested in adding (please cast your vote here if you don't mind). Unfortunately, we do not yet have a timeline on when we will have it implemented yet.
In the meantime, for some applications it is realistic to either flatten the JSON documents or to leverage collection types. For more details on flattening documents, Kirk Evans has a really good blog post on the topic.
I am really new in c# programming. I would like some help from you guys (if possible). I have a website (it is a shopping website ) with data : products, price, description...etc. What I would like to do is: Since the website has a search capability so I would like to get the data from it by querying the search link and get only the important data (product id, name, price and description). When I perform the search I get many pages, and every time I press next I get new page with extra list of products. How can I simply make automation of these tasks?
I searched a lot over internet I found that I need to use webclient() with regular expression, and I thought that maybe a loop over the page content and over the search result pages would be necessary.
what do you think guys?
Website Example.
I´ll appreciate any effort from your side.
What you're describing is called scraping.
What you'll want is to use something like HtmlAgilityPack to get the website. Then you find the nodes you're interested in by using the DOM, and reading their inner text.
The whole process is rather complicated, but at least I've sent you off in the right direction. For the most part, search urls tend to have the same format.
In your link for instance
http://cdon.se/hemelektronik/advanced-search?manufacturer-id=&title=.&title-matchtype=1&genre-id=&page-size=15&sort-order=142&page=2
You can change 'page' to be smething else and you can go through all the pages that way.
Added:
Also don't TRY to use regex to parse html. It drove one particular person mad...
RegEx match open tags except XHTML self-contained tags
I don't know how to ask this, and I don't know what it is called either so I'll just describe what I want to achieve.
In the database, some articles' title originaly has spaces:
my title with spaces
But in the url, spaces are replaced by other characters such as plus sign (+) or underscore (_)
http://www.mydomain.com/mycontroller/myaction/my_title_with_spaces
or
http://www.mydomain.com/mycontroller/myaction/my+title+with+spaces
Now, how do you do that in C#? Or is there any helper in ASP.NET MVC that can do something like that?
Let say we achieved the said URL, is there any risk that two unique titles become the same in the URL? Please consider these titles:
Title's
Titles
after parsing, they became the same
Titles
Titles
This will be a problem when retrieving the article from the database since I'll get two results, one for "Title" and one for "Title's".
I would implement that functionality like this:
1. When creating a new article, generate the URL representation based on the title.
Use a function that converts the title for a suitable representation.
For example, the title "This is an example" might generate something like "This_is_an_example".
This is up to you. You can create a function that parses the title with rules you define, or use an existing one if it suits better your problem.
2. Ensure the URL representation is unique
If it's going to be an ID, it must be unique. So, when creating new articles you must query your database for the resulting URL representation. If you get a result from the database, it means the newly created article generated the same representation as one of the already created articles. Add something to it so it remains unique.
This could be something like "This_is_an_example_2". In this case, we added the "_2" to the end of the generated representation so it differs from the already existing one. Once more, with each change you have to ensure this representation remains unique.
3. Save the created ID in the database, along with the article data
In the database be sure to save the "This_is_an_example" ID and relate it to the article. Maybe even as the table primary key?
4. Query the database for the correct article
Now, about showing a site visitor the correct article:
When a visitor asks for the following resource, for example:
http://www.mydomain.com/mycontroller/myaction/this_is_an_example_2
Extract the URL part that identifies the article, in this case "this_is_an_example_2".
When you have that, you have the identifier of the article in the database. So, you can query the database for the article with the "this_is_an_example_2" ID and show the article's content to the user.
This might involve some URL rewriting. Unfortunately I'm unable to help you with that in asp.NET. Some search on the subject will surely help you.
In database I have a list of hierarchical list of categories so i construct a Custom Sitemap provider (by extending StaticSiteMapProvider ) with this list of categories.
Now, the page that display articles /ShowArticle.aspx?id=" + Eval("ID") is rewrited into:
/id/article-title.aspx.
So it's not physical exists.
I want the following: When the selected page is displayed I want to display the complete category path in the "Bread crumbs" (every article has a "category" property that contains it's 1 lvl category - without parents)
For example categories structure:
Home
Products
CdRom
DvdRom
Toshiba
Support
Hardware
Software
When an article id=xx,category=Toshiba, title="Best Toshiba DVD" is opened, the path in "Bread crumbs" should be:
Home|Products|DvdRom|Toshiba|Best Toshiba DVD
How to do it? Should I add something to my custom Sitemap provider?
I don't get any answers :(
Maybe I should do like this:
Instead constructing the site map for categories, i should construct it both for categories and all available articles in the database.
It's not efficient (even with caching), but it's the only way i think.
What else can I do?
Update:
What is left is just to create dynamically list of links that will act as bread crumbs,
when an article is opened it's containing category will be read and full hierarchical categories path will be calculated (from root to this current node).
I had to look up what the SiteMap provider was, and in doing so accidently came across the answer you may be looking for on the MSDN website: Breadcrumb using SiteMapPath Class
It might not be quite what you are after but it could be a point in the right direction :)
Web pages have moved to use URLs like:
//weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx
i.e. they include the title of the page in the url rather than having some coded id.
I understand that this is useful for SEO, and also for users in finding the correct page where they wish to type in the url.
I would like to follow this approach, but wonder how best to acheive it, and particularly how to deal with duplicates.
Is a database trigger which creates the url based on the title and adds a numeric incremental suffix to any duplicates the best way to go, and if so what would such a trigger look like?
Instead of having an id based on a title they could use id based on both a date and a title (2007/12/03/asp-net-mvc-framework-part-2-url-routing). So if you don't have articles with the same titles in one day (which isn't too severe restriction) duplicates are eliminated.
In Wordpress at least, the "slug" (as they call it) is generated once from the item's title and stored separately in the database. If two "slugs" collide, it appends -1, -2, etc. to the end. I personally prefer if you add an (optional) field to the submission form to allow people to insert their own—it allows people to specify a shorter URL than my-long-article-is-hard-to-type.
You've got to model this concept in your application. URL generation based on title can be automatic, but it can't be invisible. WordPress (and probably other CMS's, too) do a pretty good job of this -- they'll default a URL based on the information you enter, but the "key" part of the URL is visible and editable to the user, and uniqueness is enforced at the appropriate level (globally, per month, per day -- whatever).
Making URL generation completely invisible will lead to confusing errors for the user, I believe.
You could do the same thing that SO does. That is, the slug is only there as GoogleJuice. These two URLs resolve to the same thing:
ASP.Net MVC - route object id == title - how to deal with duplicates?
ASP.Net MVC - route object id == title - how to deal with duplicates?
So, in the example you gave, if the CMS gave each post a unique numeric identifier (which I suppose is quite likely) then you can include it in the URL:
http://weblogs.asp.net/scottgu/archive/2007/12/03/1234/asp-net-mvc-framework-part-2-url-routing
In this example, the symbol 1234 is the post's identifier.