Posts

Strongly Typed Views in MVC

Image
When you add a new View in MVC, you get an opportunity to create it strongly typed. In the image given below, when you check ‘Create a strongly-typed view’ and select the ‘Model class’ you get following code snippet on the view page.

HTML Encoding in MVC

Image
One of the best feature in Razor view engine that I like most is ‘HTML Encoding’. In many cases (like a comment form on blog) we receive the data from users and he may be trying to victimize us by sending some malicious scripts causes cross-site script injection attacks (aka XSS attack).

Deploying an ASP.NET MVC 4 Web Application on Windows Azure

Image
In this video you will learn how to deploy ASP.NET MVC 4 Web Application on Windows Azure environment. Sorry for the noisy video.

The database principal owns a schema in the database, and cannot be dropped. (Microsoft SQL Server, Error: 15138)

Image
Today I added a new user in my existing database for some web application experiments and when I tried to delete the user I received following error message.

Modernizr Library in MVC 4

Image
In this post you will learn how developers take the advantage of  Modernizr   in MVC 4 Applications.

Twitter RSS Feed Reader in MVC 4

Image
In this blog post you will learn how to setup the Twitter RSS Feed Reader in MVC 4. I’m using the same technique I used in my last post to read the Facebook feeds. Let’s look at the image that we will be creating using the given code.

Facebook RSS Feed Reader in MVC 4

Image
In this blog post you will learn how to setup the Facebook RSS Feed Reader in MVC 4. Let’s look at an image of what we will be creating in this post; see:

Adding Email, Details field in UserProfile DB Table in MVC

Image
In this post you will learn how to add Email and Details columns to an existing database. We get this database when running an application trying to create a new user account. As you know, we don’t see an email field in a user registration form as well as in the membership database. But we can enable this using some quick changes in the application. Read on.

Monthly Blogging Report: October 2012

Consolidating all blog posts monthly are very refreshing as it gives me chance to go back and see what I did in last month and for readers gives the chance to see what he not followed up.

Example on View to Controller (HttpPost) & warn on duplicate entry & delete duplicates in MVC

Image
This is a quick response post to the blog reader ‘V Patel’ who asked this question yesterday. Here is the question:

JQuery UI Datepicker in MVC 4

Image
Today, I spent couple of hours in finding solution to enable the use of Datepicker in MVC 4 Application.

Filter Records in MVC

Image
In this quick post you will learn various ways to filter records in MVC. Before starting let’s have a quick look at a controller and view page that I will use in this article. I will be using the SQL Server Northwind sample database in this article, you can download it from the Microsoft website and set up the same project to explore it.

Partial View in Razor MVC

Image
Partial View allow us to put HTML and C# code into a file that we can reuse across multiple other views. This is very useful when you work on a large application.

Html Helper for Image (@Html.Image): Developing Extension in MVC

Image
Today I worked on a project where I required to display image on the web page. As you know there is not a Html Helper for Images yet. Look at the screen, we can’t see an image here.

HandleErrorAttribute OR Error Handling in MVC 4

Image
HandleErrorAttribute in MVC is used to display friendly error pages to user when something goes wrong in the application. Let’s create a simple exception in the application to explore HandleErrorAttribute.

Various ways to pass data from Controller to View in MVC

Image
There are various ways to pass data from a Controller to a View. I'm going to discuss how Controllers interact with Views and specifically cover ways you can pass data from a Controller to a View to render a response back to a client. So, let's get started.

What happens when database doesn't match conventions / using OnModelCreating() feature?

Image
This is just basic article and I’m not going to say anything new here but I will say things in my way.  The very well-known question newbies ask about MVC and Entity Framework is, how does a conceptual database model target the names?

MVC Bind Attribute like [Bind(Exclude = "Name")] or [Bind(Include = "Address, Payment, EmailID")]

Image
When we have an ASP.NET MVC View that accepts user input and posts those inputs to a server we have the option to use the built-in Model-binding features to provide more control and security, we can restrict the properties that are allowed to be bound automatically.

The name 'Scripts' does not exist in the current context

Image
There is a very small bug in the MVC 4 Empty Template that can be seen when you create a new MVC 4 Application with an "Empty" template and start adding views for CRUD operations (using scaffolding). And when you run the application and try to navigate (to  http://localhost:port/controller/Create  or  http://localhost:port/controller/Edit ) in "Edit.cshtml" and "Create.cshtml" views, you get the following error:

Creating ASP.NET WebApplication/ASP.NET MVC Application Membership Database on SQL Server rather than LocalDb

Image
I was asked this question from one of my blog reader: How can a DB be created in SQL Server rather than locally (LocalDb) which is default?

Using image with HtmlHelpers or @Html.ActionLink

Image
Sometimes we need to serve image with the link and with the release of Razor syntaxes we have HtmlHelpers like Html.ActionLink() that has nothing like image.

Is it really necessary to remove our original accent (क्या वास्तव में अपने मूल लहजे/स्वर को दूर करने की आवश्यकता है)?

Image
Look, I’m not a speaker and even can’t guide anybody on such questions. Now, I would like to share complete chat with the great people when I asked a question about Bihari Accent on Facebook. I received really great amount of inputs/feedbacks from industry leading IT experts and they all have huge experience in the same. Once again, I would like to thank to all of them for their inputs/feedbacks. Actually, I’m bit shy and lack of self-confidence that causing all that but it will got out with the time, for sure. For example, I am writing this post in English and I learned this with the time. Now, let me share the screenshot of the question I asked and entire valuable replies.

Unable to retrieve metadata for 'MusicStore.Models.Album'. Using the same DbCompiledModel to create context against different types of database servers is not supported. Instead, create a separate DbCompiledModel for each type of server being used.

You will get this error in the step by step tutorial (on page here ) provided by Microsoft that starts from here .

Entity Framework Console Applications with SQL Server Compact

Image
Microsoft SQL Server Compact Edition is an embedded database system that allows us to integrate it in our Web, Desktop and Mobile applications.

Entity Framework's Database Seed Method

Image
The Entity Framework can automatically create/update/drop databases when the application runs. We can specify that, this should be done every time application runs or only when the model is out of sync with the existing database or in other word it runs whenever model changes. You spent time to insert records in database and when you made any changes in model, Entity Framework deletes your database as well as records.

Mapping Table-Valued Functions (TVFs) using Entity Framework Database First

Image
Entity Framework 5 brings number of improvements and Mapping Table-Valued Functions (TVFs) Support is one of them.

Spatial Data Type Support in Entity Framework 5

Image
Entity Framework 5 brings number of improvements and Spatial Data Type Support is one of them.

Monthly Blogging Report: September 2012

Consolidating all blog posts monthly are very refreshing as it gives me chance to go back and see what I did in last month and for readers gives the chance to see what he not followed up.

TypeScript: JavaScript like Programming Language by Microsoft

Image
Okay, here is a great news, Microsoft has released a developer preview of TypeScript, a new programming language like JavaScript that is translated into JavaScript so that its apps can be run in any browser. In other words, TypeScript is a superset of JavaScript and you write it like you write JavaScript. And today, I explored it and I am sharing it with you.

Playing with Entity Framework's Code First Database Migration

Image
In this video you will learn how to use Entity Framework's Code First Database Migration. I'll create simple console application and will add 'Student' model and then a DbContext in the project.

Enum Support (EF Designer) in Entity Framework 5

Image
Entity Framework 5 brings number of improvements and Enum Support in EF Designer or Code First is one of them. In this post you will learn it by creating a simple console application then will add EF Designer and will sketch the Model on designer surface. Please note, EF Designer can also be used with the Database First workflow to map to an existing database.

Enum Support (Code First) in Entity Framework 5

Image
Entity Framework 5 brings number of improvements and Enum Support in Code First is one of them.

Normal LINQ Query to Compiled LINQ Query to Auto-Compiled LINQ Queries in Entity Framework 5

Entity Framework 5 brings number of improvements and query performance improvement is one of them. In this article I’ll be talking all on query performances (EF1 to EF5) so that you can understand the improvements better.

TCP is a STATEful protocol and HTTP is a STATEless protocol, why?

One question i was asked in MCA Class today by a smart guy is Sir, I have a doubt, HTTP is based on TCP protocol and as we know TCP is a stateful protocol then why HTTP is stateless?

How to copy text from one textbox to another using jQuery blur

Here is a questing I received Hi Help me on jquery blur event I need to copy data from one textbox to another textbox.

Code First Database Migrations in MVC: in Hindi

Image
In this video you will learn how to use Migration feature in MVC Apps. I will create a new MVC Project using Code First Approach and then I will make some changes in model to look at the errors and then will use the Migration feature to migrate/update the database. Video is in Hindi Language.

Using Stored Procedure & Entity Framework in MVC 4 to create CRUD Apps: in Hindi

Image
In this video you will learn how to create CRUD Apps in MVC 4 using Stored Procedure and Entity Framework.

HTTP Error 404.0 - Not Found in MVC

Image
The Resource you are looking for has been removed, had its name changed, or is temporarily unavailable. I saw this error today while working on a MVC Web Project, this is a common error we get while running website and performing any CRUD (Create, Read, Update, Delete) operation. Stackoverflow is full of such queries so I decided to post the fix here. You might not find it useful for your case but I think majority of requests can be satisfied.

Browse With Option (Set Multiple Defaults) in Visual Studio 2012

Image
In Visual Studio 2012 we got some really exciting new features. And setting multiple defaults to browse with option is one of them. So, watch the video and see how it really works.

Media Only Queries in CSS3 / @media only screen and (max-width: 900px) { attributes; }

Image
If you remember, CSS2 added support for the media="screen" way of defining which stylesheet to use for which representation of the data. Now CSS3 added a new feature to this functionality, by adding media queries. Basically, this means you can change stylesheets or styles on the web page based on for instance the width and height of the viewport/browser.

The type 'System.Data.Objects.ObjectContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

Today, I was developing an web application, I got titled error. I decided to post the fix for this.

ASP.NET Session States in SQL Server Mode (Session State Story)

Image
A session is defined as the period of time that a unique user interacts with a Web application. Active Server Pages (ASP) developers who wish to retain data for unique user sessions can use an intrinsic feature known as session state. Programmatically, session state is nothing more than memory in the shape of a dictionary or hash table, e.g. key-value pairs, which can be set and read for the duration of a user's session.

Free ebook: Beginning LINQ

Image
A new fashion to write Queries and address the impedance mismatch between programming languages and database. This e-book is based on my series of LINQ posts and I’m just consolidating all blog posts here. Get it Now PDF Version Download Size: 1.10 MB Total Pages: 36 Written  by Abhimanyu Kumar Vatsa ( itorian.com ) and Edited By: Deepak K Gupta .

LINQ Query Syntax and Method Syntax - Part 11

This is eleventh part of the ‘LINQ’ series posts that I have started from here . In the last post you learnt how to perform calculations in LINQ query. Now, in this post you will look at some differences between LINQ Query Syntax and Method Syntax used in LINQ.

Free ebook: Introducing Windows Server 2012 (RTM Edition)

Mitch Tulloch has updated his very popular free ebook on Windows Server 2012 based on the RTM version of the software.  A key feature of this book is the inclusion of sidebars written by members of the Windows Server team, Microsoft Support engineers, Microsoft Consulting Services staff, and others who work at Microsoft. These sidebars provide an insider’s perspective that includes both “under-the-hood” information concerning how features work, and strategies, tips, and best practices from experts who have been working with the platform during product development. More Here

Performing Calculations in LINQ Query - Part 10

Image
This is tenth part of the ‘LINQ’ series posts that I have started from here . In the last post you learnt how to transform source data/object into XML file and in this post will go ahead and learn how to perform some calculations in LINQ query.

Transforming Data Source objects into XML using LINQ - Part 9

This is ninth part of the ‘LINQ’ series posts that I have started from here . In the last post we explored customizing the LINQ’s ‘select’ statement to select subset of each source element. Now, in this post you will learn how to transform data source objects into XML.

Customizing LINQ’s ‘select’ statement - Part 8

This is eighth part of the ‘LINQ’ series posts that I have started from here . In the last post we explored how to join data from multiple data sources using ‘concat’ key. Now, in this post you will learn how to customize the LINQ’s ‘select’ statement to select subset of each Source Element.

Joining Multiple Data-Sources using 'Concat' Key in LINQ - Part 7

This is seventh part of the ‘LINQ’ series posts that I have started from here . In the last post we explored how to filter, order, group and join in LINQ. Now, in this post we will take a look at concate key used LINQ query to do joins.

My Speaking or In-Person Events

Okay, great to see you on this page. Here, i will list upcoming/past events in which i will be speaking. Hope to see you at event. 28 September 2019 By: Microsoft .NET Conf Topic: Building Full-stack C# Web Apps with Blazor in .NET Core 3.0 https://www.meetup.com/en-AU/Geek97/events/264182010 https://www.facebook.com/OfficialSunnySharma/posts/2544840485538206 05 October 2018 By: Microsoft App Innovation Circle Topic: Full day hands-on-labs on Cross platform Mobile app development with Xamarin https://www.microsoftevents.com/profile/form/index.cfm?PKformID=0x5004525abcd&wt.mc_id=AID730486_EML_5716749&fbclid=IwAR3LRmiUtTQ8dJvwc3nxeKJlUCtiZlXblJcmJRC68EcO5rdM-680vzHbaz8 30 May 2018 By: Microsoft App Innovation Circle Topic: Full day DevOps Workshop https://www.facebook.com/abhimanyukumarvatsa/posts/1934757206548496 21 April 2018 By: Microsoft Global Azure Bootcamp Topic: Getting Started with Cognitive Services URL: https://www.youtube.com/watch?v=dUt5pCcb_

Popular posts from this blog

Migrating database from ASP.NET Identity to ASP.NET Core Identity

Customize User's Profile in ASP.NET Identity System

Lambda two tables and three tables inner join code samples