asp.net-mvc

How to do long static urls in asp.net mvc

Hi, what would be the best way to create long static urls in asp.net MVC? For example say I wanted to create the following url. Ex: /Packages/Somepackage/package a ...

Using the conditional operator in conjunction with IsAjaxRequest to return ActionResult

Since there is no implicit conversion between Mvc.JsonResult and Mvc.ViewResult I cannot just utilize a conditional operator but instead end up with a cast. Which leads me to my question is the performance hit I will take for boxing the JsonResult worth it or should I just do a normal if...else block? The code below appears inside a no...

Is ASP.NET MVC appropriate for highly-secure public-facing sites?

I'm looking at using ASP.NET MVC for a current project but I have some concerns regarding security. The site is public-facing through HTTPS and is required to be very secure. Are there any legitimate reasons why I should avoid ASP.NET MVC? Is there anything I need to be aware of if I go down this path? ...

Asp.net MVC overiding default getter and setters for linq to sql, for doing UTC conversions

Hi All, I'm getting to a point with my app where I'm about to try to roll out utc support. I've already got it all working and have written myself two utility classes, called convertToUtc and convertFromUtc. I think you can guess what they do. What I was thinking though, could I build these into the getter and setter methods for my da...

How to use ASP.NET MVC MasterPage with asp.net form?

I need to use some postback powered controlls in asp.net so I decided that my project partially will use pure asp.net not asp.net MVC, but I want to use the same master file. Is it possible? So far I get this error: Server Error in '/' Application. Object reference not set to an instance of an object. Description: An unhandled except...

Upload file without loading to ram in asp.net mvc

Hi, i've notice that this was not asked before so i want to ask this question... currently im writing an upload controller to upload some quite a large files. but i notice when it upload large file, the CPU and RAM go peak and this is really not what i want to (of course you too) my controller is look like: int Count = 0; stri...

MVC Validation Error Messages not hardcoded in Attributes

I have a requirement that the validation error messages that are passed to my view come from the database. I want to use data annotation on my model but the error message key in validation attributes can only be a string or a constant. I'm open to other solutions for validation but I need to pull the error messages from the database. ...

Partial View getting URL paramater

I have a view named UserVerify with a returnUrl parameter, http://localhost:50383/register/UserVerify?returnUrl=http%3A%2F%2Flocalhost%3A50383%2Fregister%2Forganization. The UserVerify view has a partial view control, LogonControl. <% Html.RenderPartial("LogonControl"); %> Here is the controller code for the LogonController publi...

Using WF for Controller/Actions in ASP.NET MVC

Edited - Seems that my original question didn't explain what I wanted clearly enough What I would like to do is use Windows Workflow to handle action requests. I know WF is quite heavy and difficult to work with, but I haven't found any other .NET-based workflow libraries that suit this task. Does anyone have any examples on how to do ...

How to apply a css class on a MVC Html.TextBox

I have the following tag in my MVC Application. How can I apply a class to my textbox? <%= Html.TextBox("username", "", new { maxlength = 50 })%> ...

Test-driven development with ASP.NET MVC - where to begin?

I've read a lot about Test-Driven Development (TDD) and I find the principles very compelling, based on personal experience. At the moment I'm developing a web-site for a start-up project I'm involved in, and I'd like to try my hand at putting TDD into practice. So ... I create a blank solution in Visual Studio 2010, add an ASP.NET MVC...

View does not display updated values when using HTML helpers in asp.net mvc

Hi , I have such a problem. I change my models fields in controller but doesn't see the changes. Here are the parts of code : this is view Index.aspx <%Html.BeginForm("Index", "First");%> <p> <%=Html.TextBox("Title") %> </p> <p> <%=Html.TextBox("Price") %> </p> <input type="submit" value="Submit" /> <%Html.End...

Dispalaying DataTable contents in MVC 1.0

Hi, I am new to ASP.Net MVC (I m using Ver 1.0), I wanted to display contents of a DataTable on my view. Wat is the easiest way to get it done? Please help. ...

Data aggregation - multiple websites, single superuser site

I have a requirement for a set of asp.net MVC websites as follows: Multiple sites, using the same codebase, but each site will have a separate database (this is a requirement), and users will login and enter data. A single site for super users where they log in and work on data aggregated from each of the individual sites. The number...

RenderAction - Using it without influence to parent

If I call RenderAction on action method which view has Html.BeginForm() with no params my form action folows the parent url. If I add any param (route values, action, etc) , form action attribute is replaced with MyChildContorller's controller name and action. How to use RenderAction without affecting parent url? ...

If property or field is excluded when model-binding, what value will it have?

The question is in the title, actually - let's say I have a simple class like this: public class Product { public Int32 ID { get; set; } public String Name { get; set; } //... } When I use it in action method, like this: public ViewResult DoSomething([Bind(Exclude="ID")]Product product] { //... } what value will product.I...

Video upload in MVC application?

Hello All, I want to upload video in my mvc application please tell me how will I do that and what necessary steps I shall follow. I am a naive user to the mvc applications Thanks Ritz ...

Efficient caching of generated images in ASP.NET MVC

I'm writing an MVC application which serves transformed versions of user-uploaded images (rotated, cropped, and watermarked.) Once the transformations are specified, they're not likely to change, so I'd like to aggressively cache the generated output, and serve it as efficiently as possible. The transformation options are stored in the ...

Moq Linq-to-SQL readonly property

I have a table aspnet_User in my model(dbml file) where I have a property UserName which is ReadOnly. I thought I could do this. var mockAsp_NetUser = new Mock<aspnet_User>(); mockAsp_NetUser.SetupGet(au => au.UserName).Returns("JohnDoe"); But then I get an exception: Invalid setup on a non-overridable member. An easy solution would ...

Sharing Viewdata across Actions in ASP.NET MVC

In mu MVC application page I've a Product page (Controller: ProductController, Action: Index) which lists all the products from DB. Now I've a "Add Product" link which offers a form to fill Product details. On submitting the from AddProduct action is called which calls for a StoredProcedure (modelled in my model class). On succesful addi...