asp.net-mvc

Using Inline C# inside Javascript File in MVC Framework

I am trying to get inline c# to work in my javascript files using the MVC Framework. I made this little test code up. $(document).ready(function() { alert(<%= ViewData["Message"] %>); }); When this code is used inside of the view it works perfectly. When I get outside of my aspx view and try this in a javascript file I get ...

System.Web.UI.Page won't let me access CurrentUser or User.Identity from a Controller in ASP.Net-MVC

When I try user = System.Web.UI.Page.CurrentUser or user = System.Web.UI.Page.User.Identity I get an error saying that the method is not defined for System.Web.UI.Page... I am trying to access it within a Controller, does that matter? I've checked to make sure that I do not have another class named Page, Why would it say the metho...

Where do I put common Methods in MVC application

I am used to having static methods in the App_Code folder, this folder is no longer available in MVC template. These static methods I use all over the site. How is it done in MVC, what is the best practice? How do you call the common methods? ...

Having Multiple Outputs for a single action

Hi guys, just a question that needs a quick answer, I have a Action, lets say, BlogPostController.List(); Which lists all the Posts in a hypothetical blog engine. I want both a HTML output of this data and an XML output of this data. Preferably I'd like to be able to address these purely by URL, for example: http://MyHypotheticalB...

Streaming large file uploads to ASP.NET MVC

For an application I'm working on, I need to allow the user to upload very large files--i.e., potentially many gigabytes--via our website. Unfortunately, ASP.NET MVC appears to load the entire request into RAM before beginning to service it--not exactly ideal for such an application. Notably, trying to circumvent the issue via code suc...

Dynamic Help for MVC in Visual Studio?

I wonder if it would be possible to download the MSDN MVC documentation, so i can use it with visual studio 2008 to get dynamic help (which is very handy).. anyone know of such a thing? ...

How do I display data in a Repeater using Entity Data Model and MVC

I am trying to follow this example: Creating Model Classes with the Entity Framework (C#) . I am getting an error when I try to this: ViewData.Model = _db.MovieSet.ToList(); In my intellisense, I do not get the ToList() Here is the code: using System.Linq; using System.Web.Mvc; using MovieEntityApp.Models; namespace MovieEntityApp....

problems with ASP MVC + Html.DropDownList() using a ModelView Pattern

Recently I posted a question about the html helper dropdownlist and got it working (here). But now I have decided it was alot smarter to switch to ModelView Patterns so I have acces to strongly typed methods in my views etc. What I did was I made some adjustments to the code in my other topic in the following way: VacatureFormViewModel:...

Would you recommend using the MVC Futures library?

Using magic strings in C# really unsettles me, so I'm thinking of using the MVC Futures library. Are there any reasons why I might not want to do this, or any gotchas I should be aware of? ...

ActionFilter to set a controller.action parameter but param req on ActionLink in View

We have a [UserNameFilter] ActionFilterAtrribute which populates the controller actions username parameter. This works nicely. However, when I use the Html.ActionLink helper stringly typed to the controller, the compiler requests said username parameter in the View. Has anyone come across this and know how to recitify? Controller Actio...

ASP.NET MVC, strongly typed views, partial view parameters glitch.

If i got view which inherits from: System.Web.Mvc.ViewPage<Foo> Where Foo has a property Bar with a type string And view wants to render strongly typed partial view which inherits from: System.Web.Mvc.ViewUserControl<string> like this: Html.RenderPartial("_Bar", Model.Bar);%> Then why it will throw this: The model item...

How do I access the ModelState from within my View (aspx page)?

How do I access the ModelState from within my View (aspx page)? ...

Generic Model Representations In ASP.NET MVC

I'm trying to implement a highly reusable web system where the source of data for the model can be changed at will. What I need is a generic type instead of relying on the type generated by either LINQ or entities. This tutorial goes over separation for high reusability but what happens if the data representation between entities and L...

Binding more than one <select> in ASP.NET MVC?

I've got a table of items, each with its own <select>. How do I bind these to the parameters of a controller method? Ideally, I'd like an array containing (for each row in the table) the value of the selected option. How do I do this? My google-fu is weak today. ...

asp.net MVC calling wcf service

I have asp.net application which i am planning to convert into asp.net mvc app. One area that i havn't found how it could be done is, App is using scriptmanager to make ajax calls to wcf service. And scriptmanager simply takes care or all element related to ajax, serializing - etc. I haven't found what i can use in mvc that replaces th...

Linq, repository pattern and database abstraction problem

Helo, i have spent some time now to solve a problem for which i have no solution till now. I have a predefined very huge database, whose structure is fixed. I use the repository pattern to create a abstraction layer between service code and database logic. The problem is, that i need to apply some processing to the database object befor...

Access application settings from ASP.Net MVC View

In an ASP.Net MVC 1.0 applicati0n, is it possible to access the application settings (MyProject.Properties.Settings.Default.*) from inside my View (aspx page)? I've tried but the intellisense and compiler don't like it. It says that it is inaccesible due to the protection level. ...

Is my IQueryable syntax correct?

The generated SQL does a cross join but as the ID's are matched it acts like an inner join but is there a better performing way to do this by actually using the join keyword in C#? Is there a way where you don't have to specify how the properties join because they are all heirarchicly related anyway Item is a Page class PageRoles is an...

How to setup MVC routes to handle old ASP classic pages redirects

I'm migrating a ASP classic site to ASP.net MVC. Is there a way to redirect the old traffic to the new one? Example: how to go from: www.mydomain.com/viewpage.asp?pageid=1234 to: www.mydomain.com/page/1234 ...

How do you take an image (passed in as a Base64 encoded string) and save it to the server in Asp.Net C#?

I want to create a function like this... [AcceptVerbs(HttpVerbs.Post)] public ActionResult SaveImage(string file, string fileName) { } Where the file is the Base64 encoded string created from the image, and the fileName is the name I want to save it as. How can I use this encoded string to write the image to the serve...