asp.net-mvc

.net mvc single admin section multiple sites

Hi, Desired outcome: 4 customer facing sites as separated projects 1 set of admin code used by all four sites My current setup is 4 Projects: Core for models/entities Data for repositories Controllers for, well, controllers Web for views Now, the Web project contains views for admin and customer facing sides. I'm wanting to split ...

Linq to sql - Define inheritancemapping on derived class

I'm building a core engine for my blog and would like to be able to extend it very easily. At the moment my code looks like this: [Table(Name = "dbo.ContentItem")] [InheritanceMapping(Code = "MyNameSpace.Items.SysRoot", Type = typeof(SysRoot), IsDefault = true)] [InheritanceMapping(Code = "MyNameSpace.Items.SysRecycleBin", Type = typeof...

asp.net mvc - what is a the scope of a variables inside a view

if i have code inside an asp.net mvc view that looks like this: <% bool admin = false; if (ViewData.ContainsKey("isAdmin")) { admin = (bool)ViewData["isAdmin"]; } if (admin) { %> ... generate table of html %> and later down the page i cr...

MVC Routing vs. Authorization/Authorize Tag

I am writing an MVC app that has two branches to travel along right from the beginning. On path authorizes with a PIN and I am using forms authentication to limit access to this section of the code. However, the other path will accept an AD log in and I need stop people from move between the branches using URLs. Should I be using a cu...

asp.net mvc - what is the best way for controllers to share objects

i am trying to share some objects across multiple controllers. what is the best way to do this. i want to avoid singletons and i would like to inject these in if possible but with asp.net mvc you are not "newing" the controllers so any help would be appreciated. ...

How to get a nice URL like "http://stackoverflow.com/questions/1074/asp-mvc"

Can anyone help me? I'm doing some tests in ASP.NET MVC. I want to implement the nice URL as stackoverflow.com routing system. For example: stackoverflow.com/questions/1074/asp-mvc domain.com/id/title Here is my code: in the Global.asax routes.MapRoute(null, "posts/{PostId}/{Title}", new { controller...

ASP.NET MVC - Validating uniqueness of a model

Hi What would be the best way to validate the uniqueness of a model? For example, making sure that only one user can have a certain username. I am using the repository pattern to interact with the database, so should I place the check int there? If so, how do I get this to filter back to the model? Thanks ...

Mocking HttpContextBase with Moq

I have a unit test fixture in which I'm trying to test a ControllerAction on an ASP.NET MVC controller that's used for membership functions on a web app. I'm trying to mock the HttpContext for the tests. The ControllerAction under test actually sets properties on the HttpContext, such as Session values, Response.Cookies values, etc. This...

Best Practices for MVC, jQuery and Handling Errors

Does anyone have a elegant way of dealing with errors in ASP.Net MVC? I constantly run into issues when dealing with requests to controller actions where the Action can be used for both normal requests and AJAX requests. The problem I have is finding an elegant way of dealing with these issues. For example, how could I handle validation...

Physical installation of MVC

When I install ASP.NET MVC, am I installing a different run-time, compiler, etc? Or, is it just GACing some managed assemblies for the framework? ...

How to use MSBuild to deploy an ASP.NET MVC application

I'm a complete noob with respect to msbuild but am encouraged to use it based on a previous answer to a question I posted a few days back. Anyhow, I'm looking for some recommendations on getting started with MSBuild ... and in particular, using it to automate the deployment of ASP.NET MVC applications. Thanks much! ...

Convert FormCollection to JSON

I have: Function SaveAnswers(ByVal collection As FormCollection) As ActionResult End Funciton And I want to turn collection to JSON, I thought there was a serializer to do this but can't seem to find it? ...

Proper way to handle maneuvering through pages using buttons in ASP.NET MVC?

I'm writing an app with ASP.NET MVC where, for various reasons, the navigation is handled through HTML input buttons. What are the Best practices on how to handle this situation? Set up a Form on the buttons where information needs to be POSTed and just use JavaScript to redirect on the buttons where information doesn't need to be reta...

What are the options for dynamically-typed .NET web development at this time?

What are you options for dynamically-typed .NET web development at this time? Ruby on Rails with IronRuby? Django (with a few alterations) and IronPython? Don't feel like going the Phalanger route. I'm done with PHP. I assume there is some way to make ASP.NET MVC more dynamic... but can you fully exploit that in .NET 3.5? There is th...

ASP.Net MVC Route not passing parameter to controller

I'm trying to learn MVC and having a rough start. routes.MapRoute( "Test", "Test/{stringInput}", new { controller = "Test", action = "TestMethod", stringInput = "" } ); doesn't pass stringInput to the method TestMethod in the controller. It comes over null. Not sure what I'm missing, it seems very simple and str...

Real time dashboards

I need to add a real time dashboard of data to a ASP.NET MVC application. The dashboard needs to be refreshed every few minutes from SQL server 2008. I was going to use ASP.NET MVC, with jQuery and AJAX. But Silverlight 3 is a possible option (each client has Silverlight 3 installed). I know WPF, is it worth the jump to SL 3 for this? ...

Why is my ASP.NET MVC project saving several copies of itself?

This is really weird behavior, let's say I have an asp.net mvc project as follow on my desktop (vista): /mvcapplication/app1 then over the course of development, I copy this solution to a briefcase on a thumbdrive so I can work on it from a laptop (xp). When I insert the thumbdrive back on the desktop, I notice it's taking longer and ...

What does the MVC Controller.UpdateModel<T>(T) actually try to do?

When I submit my MVC Page I get an IvalidOperationException from System.Web.Mvc Controller object in the UpdateModel method. the MSDN documentation states that this method does the following: Updates the specified model instance using values from the controller's current value provider. Is the value provider referencing the current ...

How to handle anchor tags properly consistently in ASP.NET MVC?

Hi, I am working on an fairly simple CRUD application in ASP.NET MVC. The rule for handling anchor tag inputs are fairly straight forward: All text inputs contains anchor tags are saved as-is in the database and will be encoded as HTML entities when rendering to the view. Currently I am doing this one by one for each text fi...

Advantage of creating a generic repository vs. specific repository for each object?

We are developing an ASP.NET MVC application, and are now building the repository/service classes. I'm wondering if there are any major advantages to creating a generic IRepository interface that all repositories implement, vs. each Repository having its own unique interface and set of methods. For example: a generic IRepository interf...