Hi
I have the model
public class PersonViewModel
{
public Guid Id { get; set; }
public string Firstname { get; set; }
public string Lastname { get; set; }
}
which is nested in an other view model:
public class ApprovalModel
{
[UIHint("MyDisplayTemplate")]
public PersonViewModel User { get; set; }
[Required]
...
var j = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?\//;
I want to restrict only one / coming at the end of the string. How can I restrict that in the above regular expression?
...
Create a controller:
public abstract class MyBaseController : Controller
{
public ActionResult MyAction(string id)
{
return View();
}
}
Than create another specific controller that inherit from MyBaseController:
public class MyController : MyBaseController
{
}
There is a view called MyAction.aspx in the Views/MyBas...
I've got the following routing in my application...
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Branding",
"foo/bar.css",
new { controller = "DynamicContent", action = "CSS" }
);
routes.MapRoute(
"Default",
"{controller}/{ac...
I am writing my first ASP.Net webpage and using MVC.
I have a string that I am building in a partial view with a grid control (DevExpress MVCxGridView). In my partial view I am using a HTML.Hidden helper as shown below.
' Create a hidden variable to pass back a comma-delimited string
Response.Write(Html.Hidden( "exclusionList", Mo...
I wonder, why everybody hates ViewData so much?
I find it quite useful and convenient. I tell you why: typically every controller action has it's own ViewModel, so it's used only once and I find it very tedious to modify ViewData class every time I need to add extra portion of data to view (adding extra field to class usually leads to m...
I inherited a solution and all of the mvc website projects in it won't open because they have been setup to use IIS instead of the built in webserver in VS.
How would I go about changing these projects back?
And why would it be beneficial not to and use IIS instead?
...
Hi,
This is from a very good book by Steven Sanderson
I am trying to follow the chapter 4 and trying to setup IOC on my mvc code from the code sample of the book but its not working.
I follow the code from page 97 to page 101 where I set up Inversion of Control and run the code but I get the following error.
A dialog box opens tryin...
Hi, let's way that one of my controller's action gets - as a parameter - an encrypted string. A problem is, that when the URL looks
MyAccount/Activate/?code=DbXQ2SQiwYYiDhC+ahAppa23P95YifE2z6uyvnhWCFE=
the 'code' parameter in that action looks like:
DbXQ2SQiwYYiDhC ahAppa23P95YifE2z6uyvnhWCFE=
(the "+" char is missing)
why ?
...
In MVC 2 I have a user control - Partial page as below.
Model has four records
id Dtext Dtext1
1 A, A1
2 B B1
3 C C1
4 D D1
On My machine - Output is as above in the ID Order which is expected.
But after deployment output is totally bizarre something like below.
D D1
B B1
A, A1
C C1
Would like to know ...
I have a controller in ASP.net MVC outputting a JsonResult like so:
return Json(new { [...] }, JsonRequestBehavior.AllowGet);
...that looks like this:
"data":{"41_A4N1A-1":0,"41_A4N1A-2":0,"41_C4G1A-1":0,"41_C4G1A-2":0,"41_R2N1S-1":0,...
However, Highcharts' docs indicate that the data is expected like this:
"data":{"41_A4N1A-1",...
We are trying to use custom routes in an ASP.NET MVC application to generate this url: 'http://example.com/Person/unnecessaryinfo-42'. The "unnecessaryinfo" is the name of the id which will make the URL hackable for the user. Below is the code for our route map. This works but my controller action ends up with "unnecesaryinfo-42" in the ...
Hello Friends,
I have this in my webconfig file...
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
timeout 2880 means how much sec or min its going to take?
How to show when my session time out I need to display SessionTimeout.aspx page...
Thanks
...
Initially, after upgrading to ASP.Net 4.0, I was receiving request validation errors, which I wanted to stop. I was able to do this by setting the httpruntime to use 2.0 of the request validation, as mentioned here:
http://stackoverflow.com/questions/1648386/request-validation-asp-net-mvc-2
However, I also need to allow longer querystr...
I'm trying to make an existing ASP.NET web forms app more unit testable by using some of the ASP.NET MVC objects, specifically HttpContextWrapper. I've seen examples of its usage and they always create a new object. I disassembled the source with Reflector and see all it does is store the passed HttpContext. But I was curious as to wheth...
When an asp.net application is notified of a URL, it routes it to the appropriate controller and specifically to the appropriate method.
Are those controllers placed upon the stack once? Or do they get instantiated again for each request?
For example, say I have a controller with a linq-to-sql class that gets instantiated in the declar...
I am looking all over for this dll but can't find it anywhere? anyone know where to get it and can help me?
Thanks!
...
I have url rewrite rules which redirect www.domain2.com to a subfolder under the root of a domain1.com (let's call this folder subproject). In my controller, I need to construct a URL to the original non modified path but the Request.Url properties (like AbsoluteUri or LocalPath) always contain the subproject subfolder.
In other words, ...
Having a string containing the following raw Json data (simplified for the sake of the question):
var MyString = "{ 'val': 'apple' }";
How can I create a JsonResult object representing MyString?
I tried to use the Json(object) method. but it handles the raw json data as an string -logically :P-. So the returned HTTP response looks...
Hello,
When I need to use a lookup I usually include the ID property in the view model class so I can use it this way in the corresponding view
<%= Html.LabelFor( model => model.LookupTableID )%>
<br />
<%= Html.DropDownListFor(model => model.LookupTableID, Model.LookuptableList, new {}) %>
having Model.LookuptableList as a property ...