asp.net-mvc

Asp.net Mvc: Jquery post array + anti forgery token

Hello, how do I post an array to an action on my controler with the anti forgery token. This is my Jquery postdata: var postData = { '__RequestVerificationToken': $('input[name=__RequestVerificationToken]').val(), 'productIds': IDs }; this is my Jquery post: $.post("MyProducts/DeleteProduct" , postData, function(data) { }); This i...

Howt to handle user's session when browser forward or back buttons are clicked in ASP.Net?

After user logs-in to a website by authenticating using his credentials, if he clicks back button in browser and comes back to log-in page, then how to restrict the user when he tries to visit other pages with out providing the credentials again? ...

Is this an ASP.NET MVC 2 Preview 1 bug, and what's the work-around?

I'm using this code in ASP.NET MVC 2 preview 1: public ActionResult List(long id, [DefaultValue(0)] long? commentId) { var model = UserComment.ForRefId(id); PageTitle = string.Format("Comments for '{0}'", SetCommentThread(id).Subject); ViewData[MvcApplication.SAnchor] = ...

Authentication and authorization in .Net

I am struggling to choose what to use for authentication and authorization for my .Net application. I am using ASP.Net MVC with C#. In Java I find Spring Acegi Securiyy very easy and good to implement to secure urls, hide menus and button and even secure my methods. Also I would be using windows Active directory to store user profile. ...

LinQ to XML query

I am using LinQ to XML to populate a dropdown list when my page loads. How can I cache the results so that I don't have to run the query each and every time the page loads? Also the xml file will only be updated once a day. Is it better to cache or just read it each time? ...

Cleaning Up Query Strings

Hi, This is more of an open question. What is your opinion on query strings in a URL? While creating sites in ASP.NET MVC you spend a lot of time thinking about and crafting clean URLs only for them to be shattered the first time you have to use query strings, especially on a search form. For example I recently did a fairly simple sear...

How to make ASP.NET MVC links written in different alphabet

I have an ASP.NET MVC application and I want to make links written in Cyrillic within the application. What are possible pitfalls from the developing point of view? To be more precise: now the link looks like:     http://mysite.ru/books and I want to make it look like:     http://mysite.ru/книги or maybe even:     http://мойсайт.ру...

MVC using Linq to Entity w/ sql encryption

Currently i am using sql encryption and would like to continue using it through Linq. I have all my CRUD stored proc's wired up to the table in order to handle the encryption/decryption on the backend. Problem is my database model see's a field type of varbinary(max) which is used for the sql encryption storage. The retrieval sp for t...

Is it possible to forward the current user's FormsAuthentication Identity to another Controller action?

Hi, I'd like to use ASP.NET MVC's views as mail template engine. For that, I am calling one controller action from another controller action using a System.ComponentModel.Component.WebClient, parse the returned web page and send it via e-mail. In this scenario, is it possible to forward the current user's login credentials (I am using...

MVC using Linq to Entity w/ sql encryption

Currently i am using sql encryption and would like to continue using it through Linq. I have all my CRUD stored proc's created and wired up to the table in the model in order to handle the encryption/decryption through sql. Main problem is that my database model see's a field type of varbinary(max) which is used for the sql encryption ...

ASP.NET MVC - Contained User Controls

I want to be able to create ViewUserControls with their own controllers so all the logic is contained completely. Right now, I have to wire up the ViewUserControls with the main controller and if I wanted to use these viewUserControls elsewhere, I would have to wire them up again. Is it possible to do what I'm hoping for? ...

ASP.NET MVC multi-site SSO using OpenID

I am putting a plan together for a series of sites that will share user account information among them. The idea is that once a user logs in using their OpenID, they can access any of the sites and it will know who they are. What are the common patterns/best practices that i could employ to achieve this? ...

Asp.net MVC Question regarding n-tier

I have studied a lot of starter kits for ASP.NET and ASP.NET MVC really is awesome compared to web forms, because it runs fast and developement is easy. But when I fit ASP.NET MVC, LINQ in a site with a lot of visitors and mostly controls based website, I got so many issues in my mind. Let's say I want to build a website which is small ...

asp.net membership can view access User object for roles

i have a lot of code like this in my controllers: private void PopulateAdminStatus() { if (User.IsInRole("Administrator")) { ViewData["isAdmin"] = true; } else { ViewData["isAdmin"] = false; } } the only reason i need to do this is to have my Views che...

dropdown combo not showing up in formCollection in controller

in my asp.net mvc view i have a select dropdown: <select id="userRole" name="userRole" disabled="true"> when i submit the form to the controller, i have the following code: [Authorize] [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(FormCollection formCollection_) { string role = formCollection_["use...

ASP.NET MVC V2 - Buddy Classes

Does anyone have an example of buddy classes in ASP.NET MVC 2 Preview 1? I can't seem to find anything on the MSDN about it but according to ScottGu they've added functionality for it in the most recent release. ...

Finding out the ContentType of a Image from the byte[]

Is there a way to find out what the ContentType of an image is from only the original bytes? At the moment I have a database column that stores only the byte[], which I use to display an image on a web page. MemoryStream ms = new MemoryStream(imageBytes); Image image = Image.FromStream(ms); image.Save(context.HttpContext.Response.Outpu...

Do you know of any real life business application made on ASP.NET MVC (commercial)?

Does any one know about any real application built on asp.net MVC framework. I am not talking about opensource projects as I am pretty much aware of it. I am more interested in knowing about any commercial website like banking, ecommerce or any other line of business application that's built on this framework. EDIT: Clarification re...

Controller and Previous view

Right now, I have an action associated with just the POST from the Index page in my MVC app. But I want a generic handler action that handles all page posts and within the POST Handler action, I want to know the view that I just came from. What I want is below: Any ideas? [AcceptVerbs(HttpVerbs.Post)] public ActionResult Gene...

Iterating over Json collection using JQuery iterates over chars of the data string

I am using ASP.MVC 1 to return an IEnumerable of objects (say, Cars): public class Car : Entity<Car> { public virtual string Make { get; set; } public virtual double Length { get; set; } public virtual string Colour { get; set; } } like this: [AcceptVerbs(HttpVerbs.Post)] public JsonResult GetRoutes() { IEnumerable<Ca...