Sitemap in MVC3 without using any third party tool - c#

I am trying to create a sitemap in Asp.Net MVC3.
Is there any control given by Microsoft to create a sitemap in MVC3 using Razor view Engine?
If not then, is it possible in MVC3 to to create a sitemap, without using any third party tool like Nuget MvcSiteMapProvider Package?

You can always roll your own, which is what I do, but here are some existing implementations:
https://github.com/maartenba/MvcSiteMapProvider
http://keyvan.io/sitemap-action-result-for-asp-net-mvc
I use something similar to the second implementation and it has worked very well for me.

Before I started contributing to MvcSiteMapProvider, I searched for an answer myself and came to the conclusion the answer is no. Microsoft didn't provide any built-in way to build a sitemap, search engine sitemaps files, or SiteMapPath controls in ASP.NET MVC, all of which MvcSiteMapProvider does.

Related

How Can I use HTML Helper in asp.net? [duplicate]

I'm liking the Razor syntax that Microsoft has developed for inline coding in their WebMatrix product (http://en.wikipedia.org/wiki/Microsoft_WebMatrix).
Now that Visual Studio SP1 has RTM'd, is it possible (and/or planned) to enable the use of Razor syntax in ASP.NET Webforms?
We (the ASP.NET team) currently have no plans to support the WebForms page model using Razor syntax. Furthermore it is unlikely that we would ever seriously consider this as the models are too different to make the two work together.
You can use Razor pages without MVC; this is called ASP.Net WebPages.
Just add .CSHTML files to a normal ASP.Net 4.0 project.
I explained how this works in my blog.
You could possibly integrate it using the RazorEngine available from Codeplex. It allows you to process razor outside of MVC. Though you don't get all the features you get from the MVC version of Razor, such as #Html and #Url and others.
I dare say that Microsoft have considered it, but there is no official word on the subject. Since you are not supposed to have C# or VB code in the ASPX file, you have to wonder about the point of adding Razor support to Web Forms. The code behind would still be a (partial) class file. You wouldn't put Razor there any more than you would put it in a class file in Web Pages or MVC. And swapping Server Controls and all that good declarative stuff for Html Helpers removes one of the key reasons for going the Web Forms route, IMO.
This really isn't that difficult to do. Working on it right now. Grab RazorEngine from CodePlex. It lets you compile Razor cshtml/vbhtml files into a class at runtime.
You can then take that class, and use it from a ASP.Net server control, inside its Render method. This is a great way to get HTML out of the body of a server control. Much, much cleaner.
Now, you can also add some methods that you can invoke from Razor. For instance, add something like RenderChild. Additionally, you could set the Server Control itself as the Model available to Razor. You could then invoke into the server control. Including doing something like grabbing one of it's child controls and invoking Render.

DISQUS comments in asp.net webforms

Hi i want to use DISQUS comments system. But i couldnt find any resource for C# asp.net webforms, examples , source code or implement. I have found a project in codeplex and CodeProject
but it seems that the code is in MVC i haven't used MVC . Where can i find DISQUS implementation code in Asp.net C# webforms? not MVC.
In most cases implementing Disqus into a website is really easy, since you're not actually building all the markup. At the minimum, you just need to add the Universal Code on the proper page templates, which links to the embed javascript file and the "disqus_thread" DIV.
At that point to make a "complete" integration, you just need to output some javascript configuration variables (using a unique identifier, URL, and title for each thread) and maybe the comment counting script and that should be it.
The only webforms-specific examples you might possibly need are how to output the article's unique ID, title and URL variables onto the page. So if you have a good idea of how to do that, you shouldn't need an existing integration.

Where do I find MVC4 templates for download and how do I install them?

I am somewhat confused. Searched a bunch of ASP.NET related sites but could not find the answer. I must be missing some search word..
I want to find a gallery of MVC4 templates (free/cheap) and apply them to my project. Where do I do that from? I found one codeplex project (http://mvccontribgallery.codeplex.com/), but when I tried applying by copying, there were a bunch of errors (it uses something called SiteMaster, while my project seems to be using something called _layout).
I see a ton of references to people using them, applying them, but I must be missing something very fundamental since I can't even figure out how to find a list of downloadable templates.
What are the simple 1/2/3 steps for finding/getting/installing a template on my MVC4 project?
You should be looking for a suitable HTML template instead of an MVC specific template.
Once you have that, you will need to modify you master template (usually Views/Shared/_layout) to use the HTML and CSS contained within the template you have chosen.
For MVC3 or MVC4 you don't need to download any template. Just install MVC4 in your visual studio 2010 version on higher and then choose option create new project and that is that. See this below screen capture:
Microsoft will provide you the default MVC project architecture or in your term MVC template automatically when you choose any of above option marked in red box.
What do you mean by mvc4 templates? I'm assuming you mean "website template". With MVC you can use any html template, there's no specific template for MVC (that's why you're not finding any of it). You just find any website template and adapt it to mvc context (put css and images under "Content" folder and put html code in _layout and use it like masterpage), not hard to do at all. In fact, so easy to do after you get the idea that no one publish a specific adapted version :)
Follow these steps:
(note: if you have Asp.Net MVC 4, 3 won't install right (for me anyway), so uninstall and install in order).
http://tedgustaf.com/blog/2011/4/installing-asp-net-mvc3-on-visual-studio-2010-sp1/

OpenSearch .net (C#) library: which one?

i would like to add OpenSearch to my C# webapplication.
does someone recommend a certain .net library? or does a custom webapplication require a tailormade opensearch implementation?
That might help:
http://blog.unto.net/opensearch/add-opensearch-to-your-site-in-five-minutes/
If you want while-you-type suggestions, you need to have a search method on the server that searches and returns the results in JSON (not XML) format. If you don't need suggestions, you just need a method that responds to the search in a normal way by pushing HTML to the browser.
Have a look at Mozilla's official documentation for creating an opensearch plugin for your site and supporting search suggestions
I suggest OpenSearch.Net (an open source fork of elasticsearch-net).
Have a look into the git repo for getting started
https://github.com/opensearch-project/opensearch-net

can I execute an aspx file in a class library and get the result as a string?

I have an c# Class Library where I need some dynamic template based text.
Instead of inventing my own template parser I thought I could create an aspx file in my project that is executed at runtime and, instead of viewing the output in a browser, I want a StreamReader or string object that holds the result.
Is that possible? And if yes, how do I do this?
You're going to struggle more than is necessary with this approach. You'd need an ASP.NET host like IIS.
Personally, I'd recommend an existing template processor. I've heard (on a Hanselminutes or DotNetRocks podcast, I think) that you might even be able to host the T4 system in your application. I'll have a look and see if I've remembered that correctly.
Update
Here's a link on hosting T4 templating in your application.
ASP.Net is designed to be run in a web server engine - you would also have to deploy this to make it work.
Calling ASPX Pages from a Library would be possible (see Cassini WebServer) but I would recommend another tool:
http://www.codeproject.com/KB/cs/T4BasedCodeGenerator.aspx
We use it in our Project - slightly adapted for our needs

Categories

Resources