asp.net-mvc

Shared data in ASP.NET MVC Views

What's the best way to provide shared data to my views? For example, I want to be able to just put <%= Model.Title %> in my master page, or something similar. In that scenario, is it better to override the ViewPage classes I need? Or just use a shared model object? I'm currently trying to do the shared model object approach -- it work...

Some Questions about Asp.net MVC

Hi I have some questions about some things in Asp.net MVC that still confuses me. a. I am still confused when I should be using <%= %> and when I should use this <% %>(this one seems to need a semi colon at the end). b. How can I fix this in VS2008? When I make a partial view and I start typing say <%= intellisense assumes I meant thi...

Questions about Javascript injection

Hi I been reading on asp.net mvc learning site about JavaScript injection and man it is an eye opener. I never even realized/thought about someone using JavaScript to do some weird ass injection attacks. It however left me with some unanswered questions. First When do you use html.encode? Like do you use it only when you are going t...

Best way to deploy an ASP.NET MVC app on IIS 7 / Server 2008?

So far, the only successful strategy I've been able to get by with is the following: Configure YOURAPP.Web to "Use Local IIS Web Server" and set "Project Url" = http://localhost/yourapp.web Click "Create Virtual Directory" In IIS Manager ensure that "Classic .NET App Pool" is selected Add wildcard mapping * named "ASP.NET-MVC" that ...

Merged CSS Fails In Firefox

In order to dramatically reduce the number of HTTP requests on my ASP.NET MVC website, I am programmatically merging the files. Essentially, I have an MVC URL http://localhost/Optimisation/JavaScript/ that calls my controller. The controller reads the javascript files in a certain order, merges them into a single output and renders it o...

How to stream partial content with ASP.NET MVC FileStreamResult

We're using a FileStreamResult to provide video data to a Silverlight MediaElement based video player: public ActionResult Preview(Guid id) { return new FileStreamResult( Services.AssetStore.GetStream(id, ContentType.Preview), "application/octet-stream"); } Unfortunately, the Silverlight video player downloads the ...

Is there a way to dynamically populate a drop down list with values from a resource file?

So I have this .resx file and I want its values shown in a drop down list in ASP.NET MVC (C#). Is this possible? Google couldn't help me, so I hope SO can :-) ...

ASP.NET MVC Compile views in separate assemblies

I'm creating a solution where I have several projects, each of them having the responsibility of dealing with entities, MVC views and controllers of a certain kind. That is, one deals with accountance, another with company management, etc. This allows us to reuse them in multiple solutions. I'm able to use the views in the different ass...

How do I do the OPPOSITE of [RequireHttps(Redirect=true)] in ASP.NET MVC

I know the easy way to get to an SSL page in ASP.NET MVC - via the [RequireSSL] attribute but I'm a little confused to the best way to do the opposite. I have many links on my site in a header bar and most of those links don't require SSL and I don't want to still use SSL. The futures project makes it very easy to redirect automaticall...

Architecting medium size asp mvc - using ninject and creating objects

Hello, I'm designing medium-size website using asp.net mvc technology. All business logic is organized into IServices (like IDomainService, IUserService, IAuthService, ITrainingService). All services are using IRepositories. I'm using Ninject 1.5 to wire services with controllers and it seems working perfectly. There is so far one subj...

How can I get Ninject 2 to use parameterless constructor for LINQ to SQL DataContext?

(Tried to post this on the ninject google group but it didn't show up so far, a few hours later..) I have started using Ninject 2 (downloaded from Github yesterday including the MVC extension project) with a project based on the following technologies; .Net 3.5 Sp1 ASP.NET MVC 1.0 LINQ to SQL Nothing magical here - I have a few repo...

How do I use Jquery UI Tabs constructor methods?

Hi I am using Asp.net MVC and I been trying to use Ajax UI tabs in jquery. On the demo site: http://jqueryui.com/demos/tabs/#ajax It has this Fetch external content via Ajax for the tabs by setting an href value in the tab links. While the Ajax request is waiting for a response, the tab label changes to say "Loading...", ...

Use tables from 2 different databases - entity framework

Hello, I have a model got from a sql 2008 database, now i need, in the same model file to create a entity that represent a user-base from another database. How I can do this in the same model and avoid creating a database view. ...

asp.net mvc actionlink shows address in FF, cannot get button to function

I'm currently in the process of learning ASP MVC and am running into a few issues. First, when I use <%=Http.ActionLink("Add / Modify", "AddModify" %> it will show as Add / Modify (/Home/AddModify) in Firefox and Add / Modify in IE. It is doing that to all links in FF and none in IE. Anyone know what reasoning is for that? Edit: ...

Using JQuery with RadioButtons to hide/show table rows

I have two radio buttons on my MVC form that I use to hide or show a row in a table. It works fine in firefox, but not IE. It seems that in IE the JQuery function is only being fired when i select the first radio button. i have added extra radio buttons to confirm that it only fires on the first. To render my buttons: ...

asp.net mvc disable browser cache

I am looking for method to disable Browser Cache for entire ASP.Net MVC Website I found following method, Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); Response.Cache.SetNoStore(); and also meta tag method, ( It wont work for me , since some MVC Actions send partial html/json through ajax, without head,meta tag...

How to change an ASP.net MVC URL

Is there a simple way of generating a new Route-URL without all this faff. I'm currently Handling several routes to the same view, all of which end with /{pagenumber} All I'm trying to do is delete everything back to the last backslash and replace the number. I was trying to avoid using the URL Maker as it seems a tad overkill for pa...

how to catch exception or error in Site.master view for ASP.NET MVC app?

In site.master view, I have some inline code like: <%=(ViewData["Name"] as Model).Name %> If ViewData["Name"] is null, the code above will cause exception. Then I want to show the customized error view to user. What I did is set error mapping is web.config like: <customErrors mode="On" defaultRedirect="~/Error/Unknown"> <e...

How do I group data in an ASP.NET MVC View?

In reporting tools like Crystal Reports, there are ways to take denormalized data and group it by a particular column in the data, creating row headings for each unique item in the specified column. If I have this: Category1 Data1 Category1 Data2 Category1 Data3 Category2 Data4 Category2 Data5 Category2 Data6 The re...

asp.net MVC: Pass query string as a string, or individual parameters?

In asp.net MVC I have a search action in my controller and I am trying to decide If I should pass the query to my repository as a string public ActionResult Search(string query) { return View(_repository.ListPeople(query)); } or as individual parameters: public ActionResult Search(string FirstName, string LastName, System.Nullabl...