asp.net-mvc

Id with / causes problems with routing

I'm playing around with Raven DB and MVC 2. By default, the id in Raven will be e.g. "suggestions/1234" for an entity called Suggestion. This causes problems with routing when I write like this: <%: Url.Action("Delete", "Suggestion", new { id = suggestion.Id }) %> The url will be /Suggestion/Delete/suggestions/14337 which won't work....

How to define route & controller structure for 2 controllers?

I want to create an MVC app to generate factsheets, but I'm not sure how to structure the routing and controllers. It consists of an index page, which acts as a template for the layout of a number of independent panels, each of which contains different types of data. I want to have a the route template like the following: /Factsheets/...

How do I use server side validation with an AJAX post?

In his blog post, Scott Guthrie describes how to enable validation using DataAnnotations. Example: public class Product { [Display(Name="Product Number")] [Range(0, 5000)] public int ProductID { get; set; } [Display(Name="Name")] [Required] public string ProductName { get; set; } [Display(Name="Price")] ...

Hierarchical Menu in MVC.NET driven by XML

I am trying to create a hierarchical xml based menu in MVC.NET <?xml version="1.0" encoding="utf-8" ?> <NavigationMenu id="1" Name="myMenu" Lang="EN"> <NavigationMenuGroup Header="Home" Name="header1" Link="/home" /> <NavigationMenuGroup Header="Manage" Name="header2" Link="/options" /> <NavigationMenuGroup Header="About" Name="he...

Microsoft Web Protection Library Can you have your own whitelist? + other questions

Hi If the Microsoft Web Protection Library can have custom white-lists http://wpl.codeplex.com/ I am also wondering do you need to do anything special to get it to work with asp.net mvc? I am going through it's methods and I see AntiXss..::.GetSafeHtml AntiXss..::.GetSafeHtmlFragment Method AntiXss..::.HtmlEncode Method AntiXss.....

ASP.NET MVC - HTML.BeginForm and SSL

Hello, I am encountering an issue with what should be a simple logon form in ASP.NET MVC 2. Essentially my form looks a little something like this: using (Html.BeginForm("LogOn", "Account", new { area = "Buyers" }, FormMethod.Post, new { ID = "buyersLogOnForm" })) I have a RequiresHTTPS filter on the LogOn Action method but when it ex...

Domain model doubts...

Hi all, From one side, I want to write a killer app(in ASP.NET MVC) ;) But from the other side, I have many doubts if I should keep to so called "best practices" at all cost. So I have a design question and I really hope you can help me out. Imagine a standard blog. I want to show 10 most recent posts. My database has standard Posts, C...

How to pass data to JsonResult in ASP.NET MVC?

Hi, this must be a newbie question. I have this method in a controller: public JsonResult GetUpdates(string lastChatMessage) { var json = Json(new {lastModeratorAction = -1}); return json; } I am calling it with $.ajax or $.getJSON from Javascript. The method gets called but there is an exception somewhere. If I use $.ajax ...

trouble constructiing url encoded link

if i do this: <a target="_blank" href="<%=Url.Encode(sitelink)%>"> LINK TO SITE</a> I get the link encoded but prepended with the current local domain "http://localhost/http://...." whats the proper way to do this ...

MVC2 + ASP.NET 4.0 + IIS6 + extensionless URLS, no longer need wildcard mapping?

I noticed that asp.net 4.0 now installs a top-level isapi plugin (in iis6), such that it can inspect every request coming to the server. Should this now allow us to run MVC applications with extensionless URLS and have the aspnet isapi process them correctly without requiring the wildcard mapping (and avoid the performance penalties asso...

RenderPartial and data passing in MVC

I am developing a site similar to a portal with loads of individual portlets. There is an Overview page and the view calls Html.RenderPartial for about 10 other shared views. All those views are strongly typed and expect some data. So, I have portlets for chat, messages, status and so on. All this data depends only on the currently log...

Profiles in MVC 2 and/or custom user registration

Hello. I am working on an MVC 2 application where I need users to add custom fields when they register, for example age, phone number, full name, etc. Investigating I found this blog entry where they use ASP.NET Profiles and customize the CreateUserWizard control. My problem has been that I cannot get this to work since in MVC I have ...

Using the ASP.NET MVC Attribute Based Route Mapper

In my ASP.NET MVC application, I want to use this ASP.NET MVC Attribute Based Route Mapper, first announced here. So far, I understand how to implement code that uses it, but I've run into a few questions that I think those who have used this attribute-based route mapper in the past will be able to answer. How do I use it with ActionR...

asp.net mvc IDataErrorInfo validation when using ViewModel

I have used IDataErrorInfo Validation for my Model. But when I use these model classes inside a view model, the validation does not happen. sample viewmodel below public class CategoryViewModel { // Category class with IDataErrorInfo public Category category { set; get; } // Subcategory class with IDataErrorInfo pu...

How to make data available when one Controller's View calls another Controller's View?

Background: I'm trying to produce dynamically generated Factsheets, where each Factsheet has a number of ContentAreas, and each ContentArea is configured to contain a number of Panels. I have a FactsheetController, a ContentAreaController, a PanelController and individual panels such as NameAndDate and AssetPanel FactsheetController p...

Is WPF and MVC same concepts ?

Hello I am new for both concepts. 1) I want to know that MVC and WPF is same concepts but WPF for desktop while other is for WEB ? 2) Will be easy to learn other one If i learn one of them ? ...

If current user isn't in role required by [Authorize], can I automatically redirect them?

In the ASP.NET MVC site I am building, I have some methods where the users who use them have to be in a certain role (as it happens, if they're not, it means that they're suspended from the site). To accomplish this, I'm using the [Authorize(Roles="RoleName")] attribute without any difficulties. However, I don't quite understand what ha...

quick FormCollection question ASP.NET MVC2

I have a simple object public class SomeObject { public Int32 id { get; set; } public string name { get; set; } } In a strongly typed view I am letting the user edit SomeObject.name, when the form is posted the receiving method doesn't see SomeObject.id in FormCollection (it does see SomeObject.name). Do I need to actually pl...

jQUERY onclick post

Hi, I want to make a POST request to my Controller with jquery. function Send() { $.post("User/Delete/1"); } <a href="#" onclick="Send()">Delete</a> It doesn't work, however if i write this code: <%= Html.ActionLink("Delete", "Delete", new { onclick = "$.post('User/Delete/1')" })%> it works fine. Unfortunetly i cant use this p...

ASP.NET MVC IEnumerable Issues with RenderPartial

Hi Guys, I have a main page which uses a ViewModel I have created: public class HomeViewModel { public List<Category> Categories { get; set; } public List<Image> Images { get; set; } public HomeViewModel(List<Image> images, List<Category> categories) { Images = images; Categories = categories; } } ...