Hi folks,
i have the following code, which fails during runtime...
var mock = new Mock<ControllerContext>();
mock.SetupGet(x => x.HttpContext.Request
.ServerVariables["HTTP_HOST"]).Returns(domain);
** RunTime Error: Invalid setup on non-overridable
property
I've got some code in my controller, which needs to check the doma...
can I have domain.com/action/id as well as domain.com/controller/action?
how would I register these in the route-table?
...
I have a rule defined as
routes.MapRoute(
"DefaultVideo", // Route name
"{action}/{id}/{title}", // URL with parameters
new { controller = "Home", title = "" },
new { id = new IDConstraint() });
Howev...
I have the following folder structure in an ASP.NET MVC 2 app using Spark.
[site root]
home
HomeController.cs
Views
Shared
Index.spark
However, if I move Index.spark into the /home folder, I get the following error:
The view 'Index' or its master was not found. The following locations were searched:
...
i'm just sending a normal POST request using Ajax.BeginForm... i output the form elements using the .TextBoxFor and .HiddenFor etc... all as i should... and when it's posted via ajax to my action method, the object in the action method (named "Comment") is not populated with the values!
Am i missing something? here is the relevant part ...
Hello,
I have reading posts all night looking for an answer to my issue and haven't found anything that works for me yet. I am sure there is a simple way to do this but I haven't been able to discover it yet.
Details:
MVC 2 Preview
Asp.net 3.5 sp1 framework
VS 2008 C# web application
Windows Server 2008
IIS 7
I have the application r...
Hi
I have three cascaded drop down lists.
ddlIllnessType, ddlIllnessSubType and ddlInfectiousAgent
Initially, only ddlIllnessType is showing. On change, ddlIllnessSubType is filled with json data and made visible. So far, so good.
Next, when the user selects a value from ddlIllnessSubType, a similar procedure runs for ddlInfectious...
I have an Asp.net MVC2 web application. I built the application using VS2008 and tested on internal server, everything was perfect but when i deployed that web application on a local IIS the paths to images in web pages and in css file was not correct.
I need to change those paths for working with internal server and local server.
How c...
I want to show the content of ViewData, which holds string in my case, on a modal window.
For this, I am using following code in my view.
<h2><%= Html.Encode(ViewData["Message"]) %></h2>
<p>
To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>.
</p>
<form runat...
Hi,
I've got a couple of questions about the naming convention for the DisplayTemplates and EditorTemplates in MVC 2.
If for example I have a customer object with a child list of account how do I:
Create a display template for the list of accounts, what is the file called?
When I'm doing a foreach( var c in Model.Accounts ) how do I ...
I have a website on with MVC, which has a dropdown in the masterpage.
The data in the database is linked to a Year. so every year we get a new clean DB to start with (or so it seems from the website, because the Year changed)
The dropdown box lets you select the year you want to edit/see/go into.
in the global.asax i have a method:
...
Hi,
I want to perform caching of data for 1 day.
In my MVC model I am getting the data from the database and the using it on my View.
I want to add the data in cache if not there.If it is already in cache then getting the result directly form there.
In my model I have a function result() in that I have used caching as
if (HttpContext....
Building or publishing my ASP.MVC 2 application the .spark files in the View directories copied to /bin/Views/*.
This redundancy seems to be useless as the app runs fine on the server even if I delete the bin/Views directory.
Any idea how to prevent this behavior?
My files are tagged with the default build action "Content" and the Vi...
This question is also related to my other question ASP.NET MVC - Website Paths.
I have a 3rd party component which has hard-coded directory paths compiled into the assembly. An example of one of the paths is:
%APPDATA%\Vendor\Product\settings.ini
So if I create a console application/windows service and run it under my account on my ma...
I have an ASP.NET MVC website deployed on IIS6 running on Windows Service 2003. Every day around 12:30 (and occasionally at other times), the w3wp.exe process goes up to 99% CPU, won't serve any pages, and will continue to remain stuck until I do an IISRESET.
I work at a small place, and I admit that it's not the optimal server setup (...
What are the benefits/demerits of using duck typed view models with asp.net mvc?
Recently I've seen an interesting implementation of a twitter search client, using fluent C# dynamic XML wrapper to pass data from the controller to the view, to wrap XML data.
It seems like a better way to pass data - viewModel.Foo instead of using View...
I have created a case insensitive dictionary in C Sharp as follows . And the following code throws an exception, since the dictionary is case insensitive.
IDictionary<string, ABCentre> names = new Dictionary<string, ABCentre>(StringComparer.OrdinalIgnoreCase);
names.Add("LC001", new ABCentre());
if (names.ContainsKey("...
Hi All,
I want to bind a collection using a prefix, like so
public ActionResult Whatever([Bind(Prefix = "Prefix")] CustomModel[] models)
I created form elements using
<%= Html.TextBox("Prefix.models[" + i + "].Property") %>
which generated html inputs like this
<input id="Prefix_models[0]_Property" name="Prefix.models[0].Property...
ASP.NET MVC is heavily convention-based, "convention over configuration" as they say. So, this means there's a lot of significance to what name things are given and where in the project structure they are created.
As a newcomer to ASP.NET MVC, I appreciate the power and simplicity of this approach, but I do find it a bit confusing to ke...
I am creating a SelectList from a List(T) class to use to populate a HtmlHelper.DropDownList in an MVC view, setting the dataValueField and dataTextField in the Select List constructor. The text that should be displayed doesn't excatly match one of the properties on my class and still needs to be manipulated. Is there any way of doing ...