asp.net-mvc

Check User.Identity.IsAuthenticated in ActionFilter right after login

I'm basically using the AccountController from the ASP.NET MVC samples. It uses FormsAuthentication to handle the user login. Just to be sure, here is the code to handle user login: public ActionResult LogOn(string userName, string password, bool rememberMe, string returnUrl) { if (!ValidateLogOn(userName, password)) ...

There is no ViewData item with the key 'taskTypes' of type IEnumerable<SelectListItem>

I'm getting the error message above when adding an onchange attribute to a Html.DropDownList in ASP.NET MVC: <td><%= Html.DropDownList("taskTypes", (IEnumerable<SelectListItem>)ViewData["TaskTypes"], "None", new { onchange = "document.getElementById('NewTask').submit()" })%></td> When the view initially loads, I do not get the error. ...

Asp.net MVC Partial View Form Submit Problem

How do i return a partial view inside a master page after submitting a form. Basically what i'm trying to do is display form validation errors, but the problem i can only manage to return a partial view not the master page or full view that its in. Any suggestions? ...

Client and Server side validation in asp.net MVC application

Hello, We are starting a new ASP.NET 3.5 MVC application. Following are the requirements for validation: Both client and server side validation. Validation rules in one place. Common scenarios like 'Password' & 'Confirm Password' are addressed. Options: DataAnnotation (ONLY does server side validation) EL 4.1 Validation Applicatio...

ASP.NET MVC Passing Data from View to Controller

I have a view with a grid that contains items added to a workstation. The user can select an item from a drop down list and click an action link which calls a controller that adds that item to the workstation. I can make it work by reading the FormCollection object in the Post action of the controller. <p> <% using(Html.BeginForm("A...

Can't create HtmlHelper methods in VB MVC app

I can't figure out what I'm missing in the following code. I've got a method that should add a (dummy) helper extension: Imports System.Runtime.CompilerServices Namespace HtmlHelpers Public Module HelpExtensions <Extension()> _ Public Function HelpMe(ByVal HtmlHelper As HtmlHelper) As String Return "<a...

Filter child elements in an ASP.NET Linq-to-Entities

I have the following type of situation: TABLE Customers ( CustomerID int, etc... ) TABLE Orders ( OrderID int, CustomerID int, Active bit, etc... ) I am using this in an ASP.NET MVC web application using Linq-to-Entities. I want to select all Customers and populate the Customer.Orders navigational property, a...

Can I use this in Repository Model?

Hey everyone, I am working on a project using ASP.NET MVC, and repository model. I have repository classes, and services which consume these repository classes. My question is: Is it correct to return a IQueryable from my repository class and then use ".Where" and ".OrderBy" in a Service to generate a List? If yes, is it the best pract...

Moving from custom authentication to Open ID.

Anyone have any recommendations on moving from a solely custom DB based authentication to Open ID? Like pitfalls and gotchas. I'd really like to provide both for those who don't like/not into OpenID. This is an ASP.Net MVC application for the record. ...

What do you do when a client requires Rich Text Editing on their website?

As we all know by now, XSS attacks are dangerous and really easy to pull off. Various frameworks make it easy to encode HTML, like ASP.NET MVC does: <%= Html.Encode("string"); %> But what happens when your client requires that they be able to upload their content directly from a Microsoft Word document? Here's the scenario: Peop...

How can I access a server-side control in a codebehind in my MVC project?

First and foremost let me state that I know that accessing server side controls in my View is frowned upon in MVC. However, I need to in my situation (as far as I can see). Here is my story. :) I have a 3rd party control that I'm using in my web application. I've currently been given the task to port our WebForms solution to MVC. This p...

Linq Select Statements - Where Not In

I'm trying to write up the LINQ statement that is equivalent to: select e.EmployeeID, EmployeeName = e.FirstName + ' ' + e.LastName from Employees e where e.EmployeeID not in ( select EmployeeID from Managers ) I think I'm pretty close with the following: from e in Employees where e.EmployeeID != // This is where I'm lost ( ...

Timing User Access in ASP.NET MVC, Beginner

In ASP.NET MVC, what is a good way (the preferred way??) to time how long a user has been on a specific page? For example, I want the user to select something and then only allow the user to do something for 30 seconds. Good links or a reference to a page of a book would be much appreciated. Thanks in advance! ...

ASP.NET MVC Ajax

I would like to have a page that checks for updates to a database table and refreshes the grid using an Ajax call and when a new row is inserted into the table pop up a message window. This database table gets updated with new rows every 15 minutes or so and the message window lets the user know that a new record has been added or possi...

MVC Html.ValidationMessage not firing on update.

I'm having an issue where my validation messages are showing up fine on an add operation, but when it comes to the update page, the validation messages are not showing: This is my action, IsValid is coming out as false, and action redirects to the edit view, but none of the validation messages are shown. Is there something wrong in my a...

Html.TextBox with css class specified conflicts with form validation css (input-validation-error)

Interesting situation. I have a Html.Textbox() that I render from a view as follows: <%= Html.TextBox("title", Model.Title, new { @class = "txt" }) %> In my controller, I have the following, somewhat simplified, validation on the title. For arguments sake, assume it finds the error, and re-renders the view with the modelstate error ...

ASP.NET web app development: hiding sensitive information from contractors/freelencers

I am developing a web application that uses Amazon Web Services. I am using ASP.NET MVC. I also use several Amazon Web Serivces including S3, EC2 and SQS. I am planning to hire freelancers to help the development. Now I put the Amazon Web Service key and secret in the web.config file and it is connected to my credit card. I am using host...

Add validateRequest = false but still getting the error

Hi, I added: <pages validateRequest="false"> to my web.config but I am still getting the error: A potentially dangerous Request.Form value was detected from the I added it to the view page also and still getting the error. How can this be? ...

Creative ways to converting a Collection of objects to a javascript array in c#

Hi, I have a List of users List<Users> and I need to make a javascript array of all the UserID's. I know I can manually build this using a stringbuilder and loop through and then save it to a variable and show it on my asp.net-mvc view page. Any other more creative ways to do this? ...

How to organize my classes?

I'm developing a small project in ASP.NET MVC to manage photos, but I don't know how to organize my classes in namespaces. I have 2 base classes (Photo and Category). Should I put these classes into which namespace? Domain? POCO/POJO? For Data Access, I have more 2 classes, PhotoDAO and CategoryDAO in DAO namespace. (Is it right?) Whi...