How to Render MetaTags in ASP.NET Page

If you need to render dynamic meta-tags in ASP.NET page you can do this trick. This ASP.NET code will define HTML meta elements on an ASP.NET Page. However, the output is all mixed in one line. So how do you separate it?

Here is the sample code:
HtmlMeta metakeywrd = new HtmlMeta();
metakeywrd.Name = “keywords”;
metakeywrd.Content = “add keywords here”;

HtmlMeta metadesc = new HtmlMeta();
metadesc.Name = “description”;
metadesc.Content = “add meta description here”;

Page.Header.Controls.Add(metakeywrd);
Page.Header.Controls.Add(metadesc);

And here’s how to make it better:
Page.Header.Controls.Add(new LiteralControl(“\n”));
HtmlMeta metakeywrd = new HtmlMeta();
metakeywrd.Name = “keywords”;
metakeywrd.Content = “add keywords here”;

HtmlMeta metadesc = new HtmlMeta();
metadesc.Name = “description”;
metadesc.Content = “add meta description here”;

Page.Header.Controls.Add(metakeywrd);
Page.Header.Controls.Add(new LiteralControl(“\n”));
Page.Header.Controls.Add(metadesc);
Page.Header.Controls.Add(new LiteralControl(“\n”));

 

Read this blog to find out more: http://www.devcurry.com/2010/11/render-dynamic-metatags-in-aspnet-page.html

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

CORS Support and Attribute Based Routing Improvement in ASP.NET Web API

aspnetwebapiThere is a lot of adaption in ASP.NET Web API since it was first released and has been working so hard on developing a lot of new and cool features. One of the great things the ASP.NET team have been working hard on open source development process as a way to collaborate more on the community and validate the features early as well as enable the community to contribute to the development.

CORS or Cross-origin Resource Sharing is a W3C standard that let web pages make requests to a different domain. This standard will relax the same origin-policy that is implemented in web browsers that restricts the calls to the domain of the resource that makes a call.

In the recent ASP.NET Web API roadmap, the intention to support attribute-based routing in ASP.NET Web API.

Read the rest of the article here:

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Windows Azure Will be Available as Infrastructure as a Service

windowsazureWindows just announced the general availability of Infrastructure as a Service support for Windows Azure. Along with the announcement is the new Virtual Machine and Virtual Network capabilities. This release is backed up by an enterprise SLA, and supported by Microsoft Support and is ready for production apps.

In addition to these features, today’s IaaS release also released these great enhancements:
New Images Templates
New VM Sizes
New VM Prices

With the new Windows Azure Virtual Machines, expect a lot of features and services to be on your way to having a better business.
Read the rest of the story in this blog: http://weblogs.asp.net/scottgu/archive/2013/04/16/windows-azure-general-availability-of-infrastructure-as-a-service-iaas.aspx

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Custom Controller Factory in ASP.NET MVC

For every MVC framework, the controller is the glue between View and Logic. The controller object is created by default controller factory object using a construction without parameters. But, in most Dependency Injection scenarios, we always want to get rid of the responsibility of instantiating a dependency from the controller instead of injecting it in the Constructor. However, the default Controller Factory can work with only parameter-less contractors and get restricted from using DI.

The solution is very easy, this article will explore certain scenarios in which you need to request from users in an MVC application and pass the Logger object to each Controller in the system.

Read the rest of the tutorial here: http://www.dotnetcurry.com/ShowArticle.aspx?ID=878

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

How to Change Tracking and Commitable Data-Binding using KnockoutJS

Two-way data binding is a great feature as long as you are fine with direct updates to your new model. But, if you want a more advanced step where UI changes can be cancelled, two-way data-binding gets in the way. There is a great solution for it using Protected Observable plugin created by Ryan Nemiyer.

 

  1. First we update KnockoutJS using Nuget
  2. Once e have the latest JQuery and Knockout update, grab the plugin using JSFiddle then save it in a new JavaScript file.
  3. Now that you have the observable code, modify the application so that you have two states, View and Edit. In the View state, you’ll see the blog item as non-editable, Edit view on the other hand will present an editable page.

 

Read the rest of the tutorial here: http://www.dotnetcurry.com/ShowArticle.aspx?ID=876

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

How to Work with Promise in Windows Store Apps

Windows Store Apps makes use of Promise, as a way to deal with the complexities involved in asynchronous programming. Its implementation is based on Common JS Promises proposal  At code level, this is an object that represents the result of an asynchronous operation and then returns a value some time later in the future. Promises make easy to work in asynchronous applications in Windows store apps.

You can wire functions on a Promise object in three phases of execution, asynchronous operation completed, asynchronous that generated in an error, and the asynchronous operation in progress.

Read the rest of the article here: http://www.codeguru.com/csharp/.net/working-with-promises-in-windows-store-apps.htm

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Git Integration in Visual Studio 2012

Visual Studio Update 2 went live a few days ago. What I like about Visual Studio is that with each official release, there are a ton of enhancements in this IDE. The most anticipating feature in this release is that you can try out Visual Studio Tools for Git.

What are the requirements?
Before you can get started, of course, you need Visual Studio Update 2. You can download the online version which is tedious if you own multiple computers or just download the offline version perfect to bring with you anywhere you want. Once the update is complete, download Visual Studio Tools for Git in the Visual Studio Gallery site.

Read the rest of the news here: http://www.dotnetcurry.com/ShowArticle.aspx?ID=879

 

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

How to Add Shopping Cart to Bakery Template Site

ASP.NET Web Pages Bakery is designed as a starting point for sites that displays products. It also has an order form for customers to specify a quantity for a specific product and provide shipping address. However, the site doesn’t provide multiple product selection. If you want a shopping cart for your Bakery site, this article will get into details in terms of design to build an effective shopping cart.

Of course, the first thing to consider is storage. There are a number of options to persist state between ASP.NET Web Pages.The next thing to consider are your users. Users will provide an identity before they can make a purchase. And for that, you need to let them register an account in your site.

Read the rest of the tutorial here: http://www.mikesdotnetting.com/Article/210/Razor-Web-Pages-E-Commerce-Adding-A-Shopping-Cart-To-The-Bakery-Template-Site

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

How to Prevent Image Leeching with Custom RouteHandler

If you noticed that there is a high number of request for image files in your web server log files, it may be that someone is linking your images from their own site. This will affect not only your server but also your hosting plan as they are hogging bandwidth from your server. If you don’t want this to happen to your site, implement custom RouteHandler within ASP.NET MVC application.

Before you begin, review the flow of execution request that typically comes to your ASP.NET MVC site. When the IIS receives the request, it passes the request to ASP.NET based on the URL or to the file extension. If you use IIS7 in integrated mode, all requests are mapped to ASP.NET but if you use IIS 6, you can set up a wildcard mapping.

 

Read the rest of the tutorial here: http://www.mikesdotnetting.com/Article/126/ASP.NET-MVC-Prevent-Image-Leeching-with-a-Custom-RouteHandler

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

How to Use SimpleMembership in ASP.NET MVC 4

Membership and Role Management has always been a part of ASP.NET core infrastructure since 2.0. However, the default membership and role provides a rigid terms of database schema and the way information are stores. SimpleMembership simplifies all that. This is because it extends the core membership and role providers so so you use a custom database to store user information.

SimpleMembership is introduced with WebMatrix and tries to address the common membership and role issue by offering a more flexible model for authenticating users.

Read more about what SimpleMembership can do for you here: http://www.codeguru.com/csharp/.net/net_asp/mvc/using-simplemembership-in-asp.net-mvc-4.htm

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS