asp.net-mvc

JSON return format in ASP.NET MVC

Hi! Actually my question is simple. I think. But unfortunately, Google can't help me this time. I want to return a JSON in my view in this format: [[0,"Mark Kordon",null,"My HTML - Mark Kordon"],[1,"John Doe",null,"John Doe Markup"]] How is this possible? Thanks! ...

How to disable binding of the route values in ASP.NET MVC?

As I know ValueProviderDictionary takes values for binding from 3 places From Post form From Route values From Query string I want to be able to disable the second and the third options. The only solution I see here is to create my own custom ValueProvider (copy-paste ValueProviderDictionary source file and remove these two options f...

JQuery Sort And Update Database

I'm trying to present the user with a list of links (properties: Title, url, visible, order). The list will display based upon their order. The user will be able to drag these into the order they want, which will update the records in the database. The user could also click a button that will sort based on the Title of the link (the t...

What am I doing wrong HtmlWriter not writing attribute

Hi I have this foreach (var columnName in columns) { writer.RenderBeginTag(HtmlTextWriterTag.A); writer.AddAttribute("href", null); writer.Write("Delete"); writer.RenderEndTag(); } When I get to this method in my html helper class that I made it goes through this for loop based on how many columns are in a string[] c...

What is the best mechanism to implement granular security (i.e. authorization) in an ASP.NET MVC application?

Suppose a high-speed developer was tasked with building a banking application which would be accessed by many different people. Each person would want to access his or her own account information but would not want others to access it. I would like to know the best practice for restricting access in an MVC application so that only the us...

How to get values out of object HtmlAttributes

Hi In asp.net mvc I always see the built in html helpers they always have object htmlAttirbutes. Then I usually do new {@id = "test", @class="myClass"}. How do I extract a parameter like this in my own html helpers? Like I am using "HtmlTextWriterTag" is their a way I can pass this whole object to the writer and it figured it out or...

How to apply css class to an html element using jquery in ASP .NET MVC?

Hi, Im trying to implement a tab menu just like the one in stackoverflow. I created html list and style them to look like tab menus using CSS. I put the html list on the master page. Now the problem is that How do you change the color of the list once it's clicked by the user? For example, If you click the stackoverflow "Users" tab menu...

Is it possible to override the default behavior of [Authorize] in ASP.NET MVC?

Hello, I wondered if/how I can override the default [Authorize] behavior in ASP.NET MVC. I know that I can create a new Action Filter, make my own attribute and so forth; I am merely interested if I can simply change the [Authorize] behavior and replace its workings with my own code? Edit: Guys and Girls. I appreciate your input but as...

Routing an hiearchical path from DB with ASP.Net MVC

Hi, is it possible to route an hiearchical path to map an relation from the database as follows: Lets say I have an tuple/entity "page" with an m-t-m relation to a "page" (it selfe) and I want to be able to combine the slug-value of each page to find an appropriate page, like so: mydomain.com/firstpage/secondpage/thirdpage where first...

Auto Escaping Asp.Net MVC

In an Asp.net Mvc application all string output is unescaped by default either you remember to escape everything with HTTPUtility or you open yourself up to XSS attacks. Now I'm a forgetful guy so I'm looking for a solution that helps me "not forget" to escape all my strings for me. Can anybody share any techniques they've used make es...

Provide user object to every view

How can I provide a user object to every view in ASP.NET MVC without having to create a ViewModel for absolutely every view I have? When using ASP.NET Membership, I just get a Profile variable in the views with the profile information, but when rolling my own I don't see a way to export that information. ...

How to get full Url from a Html Helper Class that I made?

Hi I have an html helper library that I am making and one of my plugins needs urls to be passed in. I don't want to pass in the full url since they every-time I change something around I have to go and fix all of the urls up. How can I get a full Url path in my file? Like if I pass in a relative path or something it gets resolved to a ...

How should I implement "Forgot your password" in ASP.NET MVC?

I'm using the standard SqlMembershipProvider that comes with the ASP.NET MVC demo. I'm interested in implementing a "Forgot your password" link on my site. What is the correct way for this feature to be implemented? Should I overwrite the password with a temporary one and email it to their registered email? ...

How to share an object between controllers and viewpages?

At the moment I am overriding the OnLoad event of an ASP.NET ViewPage. So that an object can be shared with all the viewpages. But I now need to be able to access that object in the controller as well; what is the best way to do so? Essentially, I want to share an object (that is unique for each user of the web app... so singleton is ou...

How do I write a link to a static file in ASP.NET MVC?

In my MVC application I have a folder full of PDF documents users should be able to view. However, my links to them don't seem to work: I get a "resource can't be found error". I'm guessing my problem has something to do with routing. What do I need to do so that the browser just renders the documents? ...

MVC - UpdateModel and DropDownLists

Hi I am doing MVC and have look-up values in drop down lists. When calling UpdateModel only values before the look-ups get updated and nothing afyer. I get no errors though. I can edit and create and use the following code in my cintroller: ViewData["SiteMaintenanceId"] = from m in this._siteRepository.FindAllSiteMaintenances().ToLi...

Best Practices for ASP.NET MVC

Basically, this 'question' is intended to pool information about best practices in the community. The reasons for this are: The distinct lack of an community based ASP.NET MVC resource for best practices. Yes, I am aware of wiki.asp.net. I'm painfully aware that the ASP.NET wiki on ASP.NET MVC is woefully small and terribly out of date...

How to use Bind Prefix?

Hi Say if I had this table in my db: Product It had ProductId ProductName ProductType Now for whatever reason I can't name my textboxes ProductName and ProductType so now my View Method would look like this public ViewResult Test([Bind(Exclude ="ProductId")] Product) So now through my playing around nothing would be matched in th...

Queue-Based Background Processing in ASP.NET MVC Web Application

Hello, How can I implement background processing queues in my ASP.NET MVC web app? While most data changes, updates etc. need to be visible immediately, there are other updates that don't need real time processing which I would like to hand off to a lower-priority background process which will take care of it at its own pace. As an exa...

What kind of performance loss can I expect when using Wildcard Mapping for ASP.NET MVC in IIS6 for images/videos?

I'm currently looking at server prices and IIS6 is looking cheaper then IIS7. I want to try out some ASP.NET MVC w/ extensionless URL's and from what I see, I can use an ISAPI or a Wild Card Mapping option. I'm planning to stream quite a lot of media and I'm curious how the Wild Card Mapping option would affect my performance. Has a...