Showing posts with label ASP.NET MVC. Show all posts
Showing posts with label ASP.NET MVC. Show all posts

Wednesday, May 2, 2012

ASP.NET Test Drive


In the upcoming versions of Microsoft Web development tools, ASP.NET makes data binding more flexible while ASP.NET MVC makes creating AJAX applications and building mobile applications easier, among other goodies in both environments.

Before the end of the year, Web developers will have a new version of Visual Studio (11), ASP.NET (4.5) and ASP.NET MVC (4). Here's a look at what's new in ASP.NET, followed by new features in ASP.NET MVC. There are enough new goodies that this article will just concentrate on what's new in the presentation layer in both toolsets.

There won't be room, for instance, for any discussion of the new features available for developers who are creating their own HttpHandlers. (Note that these are beta products, and could change before official release.)

In ASP.NET 4.5, one of the first things you'll notice if you use the Web Application template project is that the content for the default.aspx page is now completely useless. I've never been a big fan of the pages added in the default Web Application template, because most developers (I suspect) will need to replace them with their own pages almost immediately. However, the new default.aspx page (see Figure 1) doesn't even pretend to be supporting an application. Instead, the page now offers advice to the developer as to what to do next -- no detail on how to do it, mind you, just good advice (such as "Configure membership"). To be fair, the default login and change password pages are probably useful (you might be able to keep them), and the default master page is relatively innocuous.

Features:
1. HTML- and Client-Side-Related Changes
2. Simplifying Binding
3. Filtering Data
4. ASP.NET MVC 4 and Single Page Applications
5. Creating Mobile Applications

Tuesday, April 17, 2012

ASP.NET MVC, Web API, Razor and Open Source


Microsoft has made the source code of ASP.NET MVC available under an open source license since the first V1 release. We’ve also integrated a number of great open source technologies into the product, and now ship jQuery, jQuery UI, jQuery Mobile, jQuery Validation, Modernizr.js, NuGet, Knockout.js and JSON.NET as part of it.

I’m very excited to announce today that we will also release the source code for ASP.NET Web API and ASP.NET Web Pages (aka Razor) under an open source license (Apache 2.0), and that we will increase the development transparency of all three projects by hosting their code repositories on CodePlex. Doing so will enable a more open development model where everyone in the community will be able to engage and provide feedback on code checkins, bug-fixes, new feature development, and build and test the products on a daily basis using the most up-to-date version of the source code and tests.

We will also for the first time allow developers outside of Microsoft to submit patches and code contributions that the Microsoft development team will review for potential inclusion in the products. We announced a similar open development approach with the Windows Azure SDK last December, and have found it to be a great way to build an even tighter feedback loop with developers – and ultimately deliver even better products as a result.

Very importantly - ASP.NET MVC, Web API and Razor will continue to be fully supported Microsoft products that ship both standalone as well as part of Visual Studio (the same as they do today). They will also continue to be staffed by the same Microsoft developers that build them today (in fact, we have more Microsoft developers working on the ASP.NET team now than ever before). Our goal with today’s announcement is to increase the feedback loop on the products even more, and allow us to deliver even better products. We are really excited about the improvements this will bring.

Sunday, February 8, 2009

Email ActionResult in ASP.NET MVC

Don't call SmtpClient.SendMail directly within your controller actions because it directly couples your controller to SmtpClient.

Don't even create an interface IMailer and wrapping implementation of this to SmtpClient.

Instead, create a new ActionResult subclass called EmailResult. Make this class have the properties From, To, Subject and BodyData. In the ExecuteResult method use the ViewEngine infrastructure to render a view of the BodyData into your own StringWriter. You can then send the resulting content via email using SmtpClient.

Read More..

Tuesday, December 16, 2008

ASP.NET Development: MVC vs. Web Forms

ASP.NET Web Forms

ASP.NET Web forms is a mature technology that runs many large scale websites and is the traditional style of ASP.NET web development. Starting in the .NET framework version 1.0 it is the first technology where Microsoft made an effort to make web development very robust and much more simple. The web forms declarative syntax plus the event driven model allows you to take full advantage of visual designers by drag and dropping the controls onto ASP.NET pages and then writing code against them, much like Windows style development. This makes web forms development very enticing for a wide range of developers on both Windows and other platforms, where drag and drop development via visual designers is common and also provides a separation of web content and web page GUI logic. The key features of web forms include:

* Mature technology
* Rich toolset & controls
* Event driven model
* Easy state management
* Abstracts HTTP
* Feels like Windows development


ASP.NET MVC

MVC (Model View Controller) isn’t a Microsoft technology (and, it’s not even new). , it’s a pattern for web page creation that’s been around for some time now in other frameworks and just recently implemented in ASP.NET. As a developer using MVC you can get a ‘closer to the metal’ experience and finely tuned control of the HTML output, which will be exactly as you define it. Whereas web forms renders output based on your selections of controls and code, MVC is primarily your code with some HTML interspersed, so you get control of each pixel that’s rendered.

The three features of MVC, the model, view and controller are described here…

* The Model can be thought of as the data. This is going to be your fat layer, with all the goodies in it.
* The View is the UI representation of the Model. The view will render the model along with HTML, JavaScript and other page elements.
* The Controller chooses the view to be rendered and responds to user input. The view also manipulates the model, as needed, so the controller is the component that ties the Model and View together. The controller will be the most lightweight code-wise of the three.

As you can see, the MVC approach requires you to work with three objects rather than just one object (the page object) as web forms does. This object trio does give you some advantages over the traditional model:

* It’s testable, you can unit test easily
* Clear separation of concerns
* Control your output exactly
* Map URLs logically or dynamically
* Supports many web forms features (auth, caching, etc…)
* More geeky, higher coolness factor

Read More...

Tuesday, November 18, 2008

Advantages of the ASP.NET MVC Approach

As I hinted in earlier articles in this series, to overcome the deficiencies of the ASP.NET Web Forms solution, Microsoft created an alternative to Web Forms—the ASP.NET MVC framework. In the MVC framework, a whole web application is separated into three components: the model, view, and controller. We will take a close look at this approach in this article, the third part of a four-part series.
Introducing the ASP.NET MVC framework

Typically, the model component maintains state by persisting data in a database, while the view component is selected by the controller and renders the appropriate UI. By default, the ASP.NET MVC framework utilizes the existing ASP.NET page (.aspx), master page (.master), and user control (.ascx) for rendering to the browser.

The center and most important controller component takes the responsibility of locating the appropriate action method in the controller, obtaining data to use as the action method's arguments, and handling any errors that might occur when the action method runs. Then, the controller renders the requested view. Figure 1 gives a rough perspective of the way ASP.NET MVC works.

Read More..

Friday, November 14, 2008

The Future of WebForms And ASP.NET MVC

ASP.NET Themes

If you watch the ASP.NET 4.0 Roadmap talk at PDC, you’ll see that there are five main areas of investment that the ASP.NET team is working on. I’ll provide a non-comprehensive brief summary of the five here.

Core Infrastructure

With our core infrastructure, we’re looking to address key customer pain points and
improve scale and performance.

One feature towards this goal is cache extensibility which will allow plugging in other cache products such as Velocity as a cache provider. We’ll also enhance ASP.NET Session State APIs. There are other scalability investments I don’t even personally understand all too deeply. ;)

To learn more about our cache extensibility plans, check out this PDC talk by Stefan Schackow.

Web Forms

In WebForms, we’re looking to address Client IDs which allow developers to control the id attribute value rendered by server controls. We’re adding support for URL routing with Web Forms. We’re planning to improve ViewState management by providing fine grain control over it. And we’re making investments in making our controls more CSS friendly. There are many other miscellaneous improvements to various control we’re making that would require me to query and filter the bug database to list, and I’m too lazy to do that right now.

AJAX

With Ajax, we’re implementing client side templates and data binding. Our team now owns the Ajax Control Toolkit so we’re looking at opportunities to possibly roll some of those server controls into the core framework. And of course, we’ve added jQuery to our offerings along with jQuery Intellisense.

To see more about our investments here, check out Bertrand Le Roy’s Ajax talk at PDC.
Data and Dynamic Data

In Dynamic Data (which technically could fall in the Web Forms bucket) we’re looking to add support for an abstract data layer which would allow for POCO scaffolding. We’re implementing many-to-many relationships, enhanced filtering, enhanced meta-data, and adding new field templates.

There’s a lot of cool stuff happening here. To get more details on this, check out Scott Hunter’s Dynamic Data talk at PDC.
ASP.NET MVC

We’re still working on releasing 1.0. In the future, we hope to leverage some of the Dynamic Data work into ASP.NET MVC.

Notice here that ASP.NET MVC is just one of these five areas we’re investing in moving forward. It’s not somehow starving our efforts in other areas.

Read More..

Sunday, November 2, 2008

Run ASP.NET MVC on Windows Azure

If you’ve purposefully been ignoring the announcements out of PDC, I don’t blame you one bit. Everybody knew it would be the unveiling of Microsoft’s “cloud computing” initiative, and just about the only thing we didn’t know was the official name of it: Windows Azure. And of course I pronounce it wrong every time (I say “ah-jour”, as in “soup-de-jour”). It’s hard to call it “initiative” when they’re the 3rd one to bring a product to the table. ;)

One thing I was looking forward to was hearing about the ASP.NET MVC story on Azure. So color me surprised when I found out there wasn’t one. Since ASP.NET MVC is bin-deployable it shouldn’t be impossible, and doing some quick searches didn’t retrieve any results showing anybody else having tried this. Of course later I discovered that Phil and Eilon had whipped up a sample app that ran ASP.NET MVC on Azure, but was pleased to find out that the downloadable sample app didn’t work. In fact, it seemed to just be MVC stuff slapped into a WebRole project. (I’m guessing something got “lost in translation” since it wasn’t Phil or Eilon that posted the code.)

Anyway, here’s how you can get ASP.NET MVC up and running on Azure. I’ve created a Visual Studio template for this to make it easy to set up - download it here. To avoid distributing code that isn’t my own (i.e. Windows Azure SDK Samples) there are a few steps you’ll have to take. I’m presuming that you’ve already installed the Windows Azure SDK and the Azure Visual Studio tools.

One thing that running a web application “in the cloud” means is that you can instantly scale higher by adding more “instances”. This means the leaky-as-a-sieve abstraction of “session state” isn’t immediately available (finally!) since any given HTTP request could be going to a different server. The default session state provider for ASP.NET is an in-memory provider. This assumes that every request comes to the same physical machine. Session state providers have varied in their reliability and handling of scalability, but the other built-in providers include an out-of-proc provider (still same machine, but more resilient to IIS going up and down) and a SQL Server provider. None of these are enabled on the Azure platform, for good reason.

Read More..