asp.net-mvc

How to use mvcContrib template gallery for asp.net mvc?

Has any one ever downloaded and made use of the mvcContrib template gallery for asp.net mvc. I cant find where to download the templates from and there is no documentation for how to use it? ...

CMS: How to combine static pages with several stray different Controllers/Views in ASP.NET MVC 2

I am working on a CMS managing my website's pages' static content. There is a PageController (the default route www.mysite.com/pages/2/page-title is used) and the corresponding Views displaying the pages' static content that can be managed using WYSIWYG editors in the administration interface. I need to be able to specify that any arbit...

What does the 'action' part of a form tag mean in ASP.NET MVC?

When I have the following action in a form tag, what does the '/Account/Profile` part mean? <form method="post" action="/Account/Profile" Is it a Filename for a view? Is it an action? ...

When I try to upload a file in ASP.NET MVC, it shows as null

For some reason the paramater OriginalLocation is always null in the following code. What am I doing wrong? Controller: [HttpPost] public ActionResult File(HttpPostedFileBase OriginalLocation, FileModel model) { byte[] binaryData = null; if (OriginalLocation != null && OriginalLocation.ContentLength > 0) { bi...

How to access the refrenced table fields in Ilist object of ASP.NET MVC

Hello, I have 2 tables, master, detail. 1.master table have fields (id, username, plan)-->id is primary key (PK) 2. detail table have fields (srNo,id, worksummary, ... )--> srNo is PK. I have created foreign key relationship from detail to .master table for "id" field. the code is: IList<detail> objDetail=new List<detail> (); ...

In what case would you prefer ASP.NET webforms over MVC?

Possible Duplicate: Whats your choice for your next ASP.NET project: WebForms or MVC? Can you list some reasons that would make you use ASP.NET webforms for a new project, instead of MVC? I've heard a lot about the opposite, but not things that are done easier or better with webforms. I'm not talking about developer preference...

Passing an interface to an ASP.NET MVC Controller Action method

In my ASP.NET MVC app, I have an interface which acts as the template for several different view models: public interface IMyViewModel { Client Client1 { get; set; } Client Client2 { get; set; } Validator Validate(); } So, my view models are defined like this: public interface MyViewModel1 : IMyViewModel { Client Cli...

How to prevent caching of asynchronous requests?

I'm working on a sortable table, that is refreshed asynchronously when the column headers are clicked. The parameters determining the column I'm sorting by and the direction are stored in the query string. The first time I click the header, the table is sorted by that column ascending, the second time it's sorted descending. But the thir...

Binding arrays with missing elements in asp.net mvc

Hi, I am trying to bind a dynamic array of elements to a view model where there might be missing indexes in the html e.g. with the view model class FooViewModel { public List<BarViewModel> Bars { get; set; } } class BarViewModel { public string Something { get; set; } } and the html <input type="text" name="Bars[1].Someth...

ASP.NET MVC 2 - Avoiding repeatedly querying the database for static data?

What can I do to avoid the repeated loading of static data every time a page is loaded in ASP.NET MVC2? This is pretty wasteful, and I would like to fix it. My master page has the typical User Name + Company Name display in the top right corner. But because of the stateless nature of MVC, this data has to be looked up every single time...

JQuery-UI: How to pre-select a specific tab depending on which view the user cames from?

Hello, Let's say I have a page view called "PagePreview.aspx". on that page I've placed a UI tab Widget with 3 tabs, tab 1, tab2, and tab3. there's a link on each tab that leads to different pages on the site. When the user accesses the PagePreview, I'd like a tab to be pre-selected depending on the view where he comes from. For insta...

How to ignore meta tags when using the AntiXssOutputEncoder?

I'm using an Anti XSS Output encoder similar to the one htat Phil Hacck put forward here Unfortuantely, it's running rampant over my Site.master and fouling up the meta-tags like so: <meta name="robots" content="all,&#32;follow" /> And in Site.master it is written simply as: <meta name="robots" content="all, follow" /> Which woul...

File not found error with FileStreamResult controller action.

I have a controller action declared as follows: [Authorize(Order = 0, Roles = "Requester,Controller,Installer")] public FileStreamResult ExportJobCards() The body of this method builds a collection of CSV lines, and attempts to return them as a file as follows: using (var sw = new StreamWriter(new MemoryStream())) { foreach (var ...

How do I save an image in a SQL Server Database?

I want to save images that are uploaded with httppostedfilebase into a database. How do I do this? How do I structure the database fields? What code do I write to save it to the database? ...

Empty file with MVC file download.

Related to my previous question on this matter, where the file was not being produced, the file returned by the following code is now empty. My controller action is declared as follows, then has a body that generates CSV lines from records for export. The CSV generation works. [Authorize(Order = 0, Roles = "Requester,Controller,Instal...

How to ensure a user owns or belongs to a resource when navigating to a route (ASP.NET MVC)

I am wondering how to ensure that an employee cannot access information from another company). This is not an authentication / roles based question on applying roles or permissions to actions, but rather ensuring that the data somebody is try to access actually belongs to them. Users belong to a department which in turn belongs to a com...

What does mean ":" in <%: and what is the difference to <%= ?

Hi In ASP.NET MVC 2 <%: tag was introduced to replace <%= for Html helpers. But what does it mean and what is the difference to the previous one? When shall I use <%= and when <%:? Thank you ...

How do I load an image from a database in ASP.NET MVC?

I have saved an image on the database and want to display it to the user. The table the image is stored in looks like this: Images ------ ImageData Byte ImageName String ContentType String What should I do to load and show it in my View? ...

VirtualPathUtility.ToAbsolute() VS. Url.Content()

I have been working in an MVC project, and have seen both of these used. I was wondering what the difference between them is? Is it incorrect to use one over the other? My understanding is that I should be using Url.Content(), but VirtualPathUtility.ToAbsolute() seems to be working as well. ...

EditorFor with a variable length list - wrong data is displayed after deleting an item

I'm trying to create a form which will be used by clients to place an order for variable amount of models. It's similar to example from Steve Sanderson's blog, but I'm not using any javascript - I just have multiple submits in my form. Everything works fine, I can add as many items as I want, but when I delete an item always the last on...