Feeds:
Posts
Comments

Archive for January, 2010

This article is intended to provide basic concept and fundamentals of asp.net MVC (Model View Controller) architecture workflow for beginners.

Introduction:

“M” “V” “C” stands for “MODEL” “VIEW” “CONTROLLER” , asp.net MVC is an architecture to develop asp.net web applications in a different manner than the traditional asp.net web development , web applications developed with asp.net MVC is even more SEO (Search Engine Friendly ) friendly.

Developing asp.net MVC application requires Microsoft .net framework 3.5 or higher.

MVC interaction with browser:

Like a normal web server interaction, MVC application also accept request and respond web browser same way.

Inside MVC architecture:

Whole asp.net MVC architecture is based on Microsoft .net framework 3.5 and in addition uses LINQ to SQL Server.

What is a Model?

  1. MVC model is basically a C# or VB.net class
  2. A model is accessible by both controller and view
  3. A model can be used to pass data from Controller to view.
  4. A view can use model to display data in page.

What is a View?

  1. View is an ASPX page without having a code behind file
  2. All page specific HTML generation and formatting can be done inside view
  3. One can use Inline code (server tags ) to develop dynamic pages
  4. A request to view (ASPX page) can be made only from a controller’s action method

What is a Controller?

  1. Controller is basically a C# or VB.net class which inherits system.mvc.controller
  2. Controller is a heart of whole MVC architecture
  3. Inside Controller’s class action methods can be implemented which is responsible for responding to browser OR calling view’s.
  4. Controller can access and use model class to pass data to view’s
  5. Controller uses ViewData to pass any data to view

MVC file structure & file naming standards

MVC uses a standard directory structure and file naming standards which is very important part of MVC application development.

Inside the ROOT directory of the application there must be 3 directories each for model, view and Controller.

Apart from 3 directories there must have a Global.asax file in root folder. And a web.config like a traditional asp.net application.

  • Root [directory]
    • Controller [directory]
      • Controller CS files
    • Models [directory]
      • Model CS files
    • Views [directory]
      • View CS files
    • Global.asax
    • Web.config

Asp.net MVC Execution life cycle

Here is how MVC architecture executes the requests to browser and objects interactions with each other.

A step by step process is explained below: [Refer figure as given below]

Step 1: Browser request

Browser request happens with a specific URL. Let’s assume that user entering URL like: [xyz.com]/home/index/

Step 2: Job of Global.asax – MVC routing

The specified URL will first get parsed via application_start() method inside Global.asax file. From the requested URL it will parse the Controller, Action and ID.

So for [xyz.com]/home/index/:

Controller = home

Action = index()

ID = empty — we have not specified ID in [xyz.com]/home/index/, so it will consider as empty string

Step 3: Controller and Action methods

MVC now find the home controller class in controller directory. A controller class contains different action methods,

There can be more than one action method, but MVC will only invokes the action method which is been parsed from the URL, its index() in our case.

So something like: homeController.index() will happen inside MVC controller class.

Invoking action method can return plain text string OR rendered HTML by using view.

Step 4: Call to View (ASPX page)

Invoking view will return view() . a call to view will access the particular ASPX page inside the view directory and generate the rendered HTML from the ASPX and will respond back to the browser.

In our case controller was home and action was index(). So calling view() will return a rendered HTML from the ASPX page located at /views/home/index.aspx.

This is it, the whole process ends here. So this is how MVC architecture works.

Advertisements

Read Full Post »

Most of organizations use proxy server shared internet connection for their internal network. Browsing websites via proxy server requires few settings in browser itself where we set proxy server IP and port to 8080 which is default port, doing so is enough for any 1 to surf internet. But as an SQL server database programmers/developers uses SQL server management studio to connect to remote database from their client computers. Problem arises when a developer tries to connect a remote database server through SQL server management studio but CC Proxy won’t allow connecting to database directly even if developer uses all details correctly.

Why is SQL server management studio not able to connect a remote database?

A very basic thing about proxy server is that all client computers must have to pass all requests to proxy server IP, requests may be from internet browser Or FTP client Or even if its SQL server management studio.

So now if we try to connect a database with original details, proxy server (say proxy server IP is : 48.152.16.36 ) will not allow connecting to database using original Host name.

Because proxy cannot process any request directly, it must come to Proxy server IP first which is 48.152.16.36 (this is a dummy IP, I have used).

How to solve the problem:

Solution is simple; we just have to follow 2 steps as described below. Here we will be configuring CC proxy, SQL server management studio & SQL server configuration manager.

Step 1: Client side settings

Say for example we have following database server details:

Server name : hostname

Login ID : username

Password : password

Port : 1433 [ SQL server uses 1433 port by default, in case if its different then we have to do settings in CC proxy accordingly ]

Traditionally we use above given details directly to connect, if we connect from SSMS (SQL server management studio), it will take user to the screen as shown blow.

Now in above screen if we use Server name:
hostname then proxy will not process the request and SSMS will fail to connect to database server.

So rather than providing Server name:
hostname we have to set CC Proxy’s server IP which is 48.152.16.36. But only this much will not work, because we also need to request CC proxy to a specific port which is not used anywhere else in proxy server. So we will use any port, say we use PORT: 1444 instead 1433 which is default port in SQL server.

So now in above screen we have to set [Server name: 48.152.16.36, 1444] by keeping userID password as it is.

Ok so we are now done with client side settings. But this much will also not work as we have to do few port map settings in CC proxy on server as well.

Step 2: Proxy server side settings

Setting up above step 1 setting in client machine will now request proxy server with the port 1444. So we have to define a PORT MAP setting in CC proxy for port: 1444.

Below are the steps to follow for port map settings:

  1. Open CC proxy 6.0
  2. Go to OPTIONS
  3. Click on port map, it will take you to the screen as shown below

In above screen set the following:

Dest Host : hostname

Port type : TCP

Local Port : 1444

Dest Port : 1433

Save all above details , and we are done.

After this step all client machines must have to connect to database server using Proxy server IP only with a specific port ( in our case its 1444, however we can use any port but it should not be used anywhere else in proxy server).

Read Full Post »

It always becomes a headache for any blog writers while publishing any article with a rich formatting like a word document, with lots of pictures added inside the blog post.

For all the bloggers like me who have faced problem of rich formatting while posting an article in blog, so guys here is the easiest way to publish your well formatted articles from MS word 2007 itself , even without going to your Blog’s dashboard J

Microsoft word 2007 is providing a great functionality of publishing your fully formatted word document direct to your blog from word 2007 itself. And it’s even easier from the traditional way.

Here are the few steps you have to follow and you are DONE!!

Creating Blog article in word

Step 1: CREATING A NEW WORD BLOG POST

Open MS word 2007, go to menu and select NEW,

You will get the screen as shown below. Now choose “New blog post” as the RED arrow indicates below.

Step 2: WRITING A BLOG POST

Once you choose new blog post you will find the screen as shown below.

Now just like we prepare a word document prepare your full article here, with all formatting and pictures added.

Step 3: SETTING BLOG POST TITLE

As shown in below screen shot set your article title at marked place.

Publishing Blog article to your wordpress blog

Step 1: REGISTER YOUR BLOG ACCOUNT IN WORD 2007


As show in above picture, clicking on PUBLISH will ask you to register your existing blog account by using Blog URL and username/password.


CHOOSE YOUR BLOG PROVIDER as shown below. – I have configured with my wordpress Blog


Fill out all your blog details as shown below.


After submitting above form MS word will validate the details, after verification it will pop up a success message as given in below screen.

With above step now your Blog account got registered in MS word 2007.


Next to this step it will again ask for your blog’s admin username/password to publish the blog on your original blog account.

Finally you will get your article posted onto your blog and will get the message as shown below.


Managing blog accounts and setting article categories in wordpress article

Later on whenever you use word for publishing your blog articles, you will get your account registered and you can manage all your blog accounts as shown below. And also can mark any blog as default.


INSERT ARTICLE CATEGORIES IN BLOG POST

Again setting categories for your blog post is been very easy, all you have to do is just click on “insert category” button as shown below

It will show a full list of all your wordpress blog existing categories in a drop down.

You can also type any new category over here if not in list of existing.


For this article I have given example of WORD PRESS blog, but we can also configure for other blog providers like blogger etc…

!!! ENJOY BLOGGING!!! J

Read Full Post »

%d bloggers like this: