Quick post: How to access an action in different areas in ASP.NET MVC

Posted by on Comments (0)

Sometimes I like to post about something, but that thing is very simple and can be described in one or two paragraphs. Previously, I preferred not to post these kinds of things as a blog post but recently, I decided to post almost anything in my blog no matter how many characters they are. So here you go!

When developing an ASP.NET MVC 3 application, you may want to partition your application into different areas for any kinds of reasons:

The MVC pattern separates the model (data) logic of an application from its presentation logic and business logic. In ASP.NET MVC, this logical separation is also implemented physically in the project structure, where controllers and views are kept in folders that use naming conventions to define relationships. This structure supports the needs of most Web applications.

However, some applications can have a large number of controllers, and each controller can be associated with several views. For these types of applications, the default ASP.NET MVC project structure can become unwieldy.

To accommodate large projects, ASP.NET MVC lets you partition Web applications into smaller units that are referred to as areas. Areas provide a way to separate a large MVC Web application into smaller functional groupings. An area is effectively an MVC structure inside an application. An application could contain several MVC structures (areas).

For more about MVC areas, check this out: http://msdn.microsoft.com/en-us/library/ee671793.aspx

When want to develop a web application using MVC, you probably need to access actions/partial views from different areas. For example: You need to have an ActionLink to access the login action in Admin area. In order to do so, you simply need to add a RouteAttribute to your ActionLink as following:

@Html.Action("LoginStatus", "Users", new { area = "Admin" })

If you want to access root area, all you need to do is to set the area name to String.Empty:

@Html.Action("LoginStatus", "Users", new { area = "" })

Hope it helps.

Introducing an awesome asyc file uploader, “ManageMedia”

Posted by on Comments (8)

Yesterday, one of my best friends, Omid Mafakher, called and told me about one of his project which he’s working on for a while and as I checked it out, realized that this is so cool so I decided to share it with you too.

I know there are some Asyc File Uploaders available right now like AjaxControlTookit.AsycUploader and such but this control is something different! Actually, you may have seen such a thing on a few websites like Google and Facebook!

ManageMedia Snapshot

Besides, there are lots of useful features in this library as well like image resizing, watermark, background and foreground settings, etc.

Here’s the list of key features:

  • Upload file up to any size in .NET.
  • Validate the file (size, type) before uploading.
  • Upload with progress (Size, Speed, Time, Total Size, etc.)
  • Upload to temp file during upload.
  • Save uploaded file with too many configurations.
  • Manage the Image file and save in any format (PNG, JPG, GIF, BMP, etc.)
  • Save image in any size.
  • Resizing styles: "Center, Tile, Stretch, Zoom, CenterIfNoZoom, Corp (Facebook style)".
  • Set the Background and Foreground in your image.
  • Change the image Alpha and Resolution.
  • HttpHandler for generating images.
  • HttpModule for generating unsaved or deleted images.
  • web.config Section for Multiple settings to save file and image.
  • web.config Section to manage HttpHandler and HttpModule.

Fortunately, my friend has published it in CodePlex as an open source project so you can enjoy using it for free! You can click the link below to access and download this library from CodePlex:

http://managemedia.codeplex.com/

I highly recommend you to check this out! And comment your feedback here or in its official CodePlex page.

Hope you like it.

Oxite, An open source CMS based on ASP.NET MVC by Microsoft

Posted by on Comments (1)

 Oxite Logo - Photo taken from http://www.codeplex.com/oxite I know it’s a little old but in this post I want to talk about Oxite.

Oxite is a new open source blogging system based on ASP.NET MVC which built by Erik Porter, Nathan Heskew, Mike Sampson and Duncan Mackenzie.

This is a simple blog engine written using ASP.NET MVC, and is designed with two main goals:

· To provide a sample of 'core blog functionality' in a reusable fashion. Blogs are simple and well understood by many developers, but the set of basic functions that a blog needs to implement (trackbacks, RSS, comments, etc.) are fairly complex. Hopefully this code helps.

· To provide a real-world sample written using ASP.NET MVC.

As they said, this blog engine built not only for developers and as sample and this has been used in MIX Online too.

Here is some other information from http://visitmix.com/lab/oxite:

Oxite was developed carefully and painstakingly to be a great blogging platform, or a starting point for your own web site project with CMS needs. Its line-up of sexy attributes includes: provider-based architecture allowing you to swap out database and search providers (SQL Server DB, local and Live search providers included), built for testability and hence most likely to be voted "hottest in class" by TDD fans (repositories, everything has an interface, etc.), database file and string resource storage so that files get stored in database and strings stored for localization, built to take full advantage of ASP.NET MVC but broken into assemblies so that even ASP.NET WebForm developers can use the data backend and utility code, supports use of Visual Studio Team Suite (DB Pro, Test, etc.), and Background Services Architecture (sending trackbacks, emails, etc. all done as a background process to prevent delays on the web site itself).

Download it now and get some other information by click here