Saturday, 15 November 2014

Routing in MVC

Routing within the ASP.NET MVC framework serves two main purposes:

  •  It matches incoming requests that would not otherwise match a fi le on the file system and maps the requests to a controller action.
  •  It constructs outgoing URLs that correspond to controller actions.

The preceding two items describe only what Routing does in the context of an ASP.NET MVC application. 

NOTE: 
 One constant area of confusion about Routing is its relationship to ASP .NET MVC. In its pre-beta days, Routing was an integrated feature of ASP.NET MVC. However, the team saw that it would have a useful future as a fundamental
feature of ASP.NET that even Web Pages could build on, so it was extracted
into its own assembly and made part of the core ASP.NET framework. The
proper name for the feature is ASP.NET Routing, but everyone simply shortens
it to Routing.
Putting this feature into ASP.NET meant that it became a part of the .NET
Framework (and, by association, Windows). So, while new versions of
ASP.NET MVC ship often, Routing is constrained by the schedule of the larger
.NET Framework; hence, it hasn’t changed much over the years.
ASP.NET Web API is hostable outside of ASP.NET, which means it can’t use
ASP.NET Routing directly. Instead, it introduces a clone of the Routing code.
But when ASP.NET Web API is hosted on ASP.NET, it mirrors all the Web API
routes into the core ASP.NET Routing’s set of routes. Routing, as it applies to
ASP.NET Web API

Comparing Routing to URL Rewriting
To better understand Routing, many developers compare it to URL rewriting. After all, both approaches are useful in creating a separation between the incoming URL and what ends up handling the request. Additionally, both techniques can be used to create pretty URLs for Search Engine Optimization (SEO) purposes.
The key difference is that URL rewriting is focused on mapping one URL to another URL. For example, URL rewriting is often used for mapping old sets of URLs to a new set of URLs. Contrast that to Routing, which is focused on mapping a URL to a resource.
You might say that Routing embodies a resource-centric view of URLs. In this case, the URL represents a resource (not necessarily a page) on the Web. With ASP.NET Routing, this resource is a piece of code that executes when the incoming request matches the route. The route determines how the
request is dispatched based on the characteristics of the URL — it doesn’t rewrite the URL.
Another key difference is that Routing also helps generate URLs using the same mapping rules that it uses to match incoming URLs. URL rewriting applies only to incoming requests and does not help in generating the original URL.
Another way to look at it is that ASP.NET Routing is more like bidirectional URL rewriting.
However, this comparison falls short because ASP.NET Routing never actually rewrites your URL.
The request URL that the user makes in the browser is the same URL your application sees throughout the entire request life cycle.

Saturday, 4 October 2014

Page development in Sharepoint


Bydefault Sharepoint server has two types of pages. 1.Page(Wiki) 2.Web Part Page

1.Page: This is a normal wiki page. In this page we can add text, images, links, ..
2.Web Part Page : This is also a page but here we can't create any text. Only for adding webparts to the page.

We have another type of page is called Publishing page. This is the combination of both page and webpart. If we want to create publishing page means first we should show this option in page list like below.

SiteActions --> SiteSettings --> SiteActions --> ManageSiteFeatures -->  SharePoint Server Publishing ----> Activate. Now you will find the option Publishing page.


==================================

Webpart Page
SiteActions --> MoreOptions --> Page ---> Web Part Page ---> Create --> 
i.Name : SPDemoPage .... Check/uncheck :Overwrite if file already exists? 

ii.Layout : Select a layout template to arrange Web Parts in zones on the page. Multiple Web Parts can be added to each zone. Specific zones allow Web Parts to be stacked in a horizontal or vertical direction, which is illustrated by differently colored Web Parts. If you do not add a Web Part to a zone, the zone collapses (unless it has a fixed width) and the other zones expand to fill unused space when you browse the Web Part Page.
   Choose any one layout template. 
Ex.Header, Footer , 3columns  / Full page, Vertical / Header leftcol, body 

iii.Save Location : Select the document library where you want the Web Part Page to be saved.  choose any one of the following
SiteAssets / Shared Documents / SitePages

A new webpart page will be opened. now you can add webparts by click on Add a web part. 
After adding webparts to the page then click on Stop Editing option. Now page is ready.
*While adding webparts you can also drag webparts from one place to another place.

Web part  zone is like div tag in asp.net / html.
We can add / delete or move webparts from one place to another place.

Publishing Page
This page is the combination of wiki page and web part page. We have 5 types of publishing pages available. Those are
1.Articles 
2.Wiki Page 
3. Project 
4. Redirect 
5. Welcome

SiteActions --> MoreOptions --> Page ---> Publishing Page --> Create --> 
1.Page Title and Description : Enter a URL name, title, and description for this page.   

2.Page Layout : Select a page layout to control how the page will be displayed. 
  i.(Article page) body only: The article page with body only contains a rich text field.
 ii.(Article page) Image on left : The article page with image on left contains an image field and a rich text field
iii.(Article page) Image on right :The article page with image on right contains an image field and a rich text field.
iv.(Article page) Summary Links : The article page with links contains an image field and summary links. 

v.(Enterprise Wiki Page) Basic page:A basic page layout containing a single content area.

vi.(Project Page) Basic Project Page:A basic page layout containing a single content area.

vii.(Redirect Page)Redirect : This page layout contains a redirect control for automatically directing readers to any specified URL.

viii.(Welcome Page) Blank Web part page: Page layout for creating web part pages
ix.(Welcome Page)Splash : The welcome with splash contains an image field on left, a rich text field and Web Part zones arranged in a header, and 2 columns.  The left navigation pane is hidden.
x.(Welcome Page) Summary Links :The welcome page with summary links contains an image field on left, a rich text field, 2 summary links, and Web Part zones arranged in a header, a footer, and 2 columns.
xi.(Welcome Page) Table of contents: The welcome page with table of contents contains an image field on left, a rich text field, a table of contents Web Part, and Web Part zones arranged in a header, a footer, and 2 columns.

Click on Create.
Now you can add text, images ..... after completion of creating Save the page then click on Publish --> Publish ---> Enter any comments if ... Continue click

While you are developing the publishing page its status is 'Checked out' Means it is under design. So no one cant access this page. 

Like you can create all publish pages of enterprisewiki, basic project page, redirect page and welcome page.

============================================================