asp.net-mvc

Access Repository through Service or directly?

Hello, is it a good coding standard to allow ASP.NET MVC controller actions to access a repository directly (even though a service layer is present for the heavy lifting, e.g. LoginService.Authorize() ) to retrieve, add, or update data? Or should everything go through the service, and from there to the repository? ...

ASP.NET MVC with Custom/legacy template management system

Hi -- We have a legacy template management system, which basically returns html files from the disk based upon supplied input values. For example: TStoreMgr.GetTemplate(contextName, loc, "header.template") We want to move to ASP.NET MVC, but stay with existing template management system. Is it something possible? If so, is it worth us...

Compare .NET's AjaxOptions class with jQuery

I've just read an article detailing the functionality of MS's Ajax.BeginForm (http://www.aspnetpro.com/articles/2009/06/asp200906de%5Ff/asp200906de%5Ff.asp) and. Looking at the AjaxOptions members i find it very easy to understand the various functions that can be applied to a form submission. Just by looking at the table really help m...

How to send 2 sets of data back with Jquery Ajax.Post

Hi I am using asp.net mvc and I am trying to send 2 sets of database from jquery to my Mvc view. Now my view will look like this public ActionResult MyView(Product one, Product two) { } now how do I send the stuff back so everything will be binded correctly? I know how to do it with one set of data but not with 2. Like if I only ne...

Prefix routing in ASP.Net MVC like cakephp

I would like to learn how setup prefix routing like there is in cakephp for admin routing. Unfortunately I have not figured out how to do this in ASP.NET MVC. For example, If the user types in /Admin/Management, I would like controller Management.admin_index to be called, without changing the url. I tried what I thought was correct bu...

Does Microsoft Certification Have a Bleeding Edge (and how do I go meet it)?

In an excellent recent question folks talked about whether they'd choose MVC versus .NET winforms for your next project. In the hope of escaping some of the perpetual maintenance programming that seems to plague my career (and to have something to blog about), I'm going through getting .NET / ASP.NET certified. That's fine as far as th...

How to delete in linq to sql?

Hi I am very new to linq to sql and I am not sure how to actually delete a record. So I been looking at this tutorial http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx So for Update they have NorthwindDataContext db = new NorthwindDataContext(); Product product = db.Products.Single(p => p.ProductName =...

What is a fairly easy to implement Url Rewriter for Asp.Net MVC

I am rewriting some of sites in MVC. I am concerned about old links out there, some I know about and some I don't. I am looking for suggestions and code sample on how to make sure that my known and unknown links are not dead. What are your choices? I would eventually like to phase out my old links. I hope to do this by notifying my us...

How to do timezones? In asp.net mvc

Hi on my site I need to know what timezone people are from to display messages to them at the right times. So I am not too sure what to be searching for a tutorial how to do this. So what I am planning to do is a user will come to my site and they will set their timezone by selecting in from a drop down list. I will store their settin...

ASP.NET Single Worker Thread? (In Memory Session)

I'm using in memory sessions in my ASP.NET MVC application which means that I can only have one single worker thread correct? Does this mean I have parallel processing in my application (think concurrent requests) or not? Does my application accept only 1 request at a time? Edit: According to the IIS7 web site: If the application use...

Unit test model bound controller action with unbound fields

Sorry if that description isn't clear...wasn't sure how else to put it. I have a custom membership registration form that I've created. It posts to a controller action in which I use model binding to populate a "User" object. The form has a "Password" field and a "ConfirmPassword" field. The Password field binds to the User object when ...

Code re-use with Linq-to-Sql - Creating 'generic' look-up tables

Hey all, I'm working on an application at the moment in ASP.NET MVC which has a number of look-up tables, all of the form LookUp { Id Text } As you can see, this just maps the Id to a textual value. These are used for things such as Colours. I now have a number of these, currently 6 and probably soon to be more. I'm trying to pu...

Cleaning up a complex WebForms project

I'm currently working on a high-traffic online search site. They have various changes they want to implement over time, and they've indicated that ultimately they want the site re-done in ASP.NET MVC. Currently the site is an ASP.NET WebForms project; however true ASP.NET controls are rarely used. Instead there are lots of server-side ...

asp.net mvc view with masterpage binding with different models

if i have a master page that binds with ObjectA and then a View that binds with ObjectB, how does that work (or does it work at all) in asp.net mvc. master page might have: Inherits="System.Web.Mvc.ViewMasterPage<CalendarEvent[]>" %> and one of the view might have: Inherits="System.Web.Mvc.ViewPage<Tournament[]>" %> what would you...

is there any legitimate reason to use ViewData in asp.net mvc

with model binding where you can build up an object to ship and bind to the view, is there any reason to ever use ViewData ? ...

How to install an action filter in all actions in ASP.NET MVC?

Is there a way to have an action filter, like public class MyActionFilterAttribute : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext context) { ... be automatically applied to all actions in a web site? ...

ASP.NET StrongTyped Controller-Action View<TView,TModel>(TModel Data)

I'm using Asp.net MVC 1 and I would really like my controller actions to use StronglyTyped View(data) calls that enforce type checking at compile time and still let me use aspx pages under the default view engine. The ViewPages I call are strongly typed, but errors in the action's call to View(data) can't be caught at compile time becau...

ASP.NET MVC - Typesafe Html.TextBoxFor with different outputmodel

My view uses ModelX to render my HTML form and my controller action takes ModelY as input when saving the form. It seems the typesafe textbox API assumes I am using the same model in both places. Is it possible to use different models and beeing type safe without creating my own helpers ? <% = Html.TextBoxFor(x => x.Text) %> I would l...

Pass data to the view. Always through WiewData ?

I’m building an application that monitors other systems. Now I want to implement partial view, a User Control called “status”. This control shall display status information about the application.Like: user logged in, How many systems online, Latest activity. This partial view shall be rendered in nearly all other views. How shall I p...

Replace Multiple String Elements in C#

Is there a better way of doing this... MyString .Trim().Replace("&", "and").Replace(",", "").Replace(" ", " ") .Replace(" ", "-").Replace("'", "").Replace("/", "").ToLower(); I've extended the string class to keep it down to one job but is there a quicker way? public static class StringExtention { public static string ...