Hi,
I am writing an asp.net MVC 2.0 application, and I need to get username after the user logs in and pass it to other function. I tried that by simply modifying the standard LogOn method for AccountController, here is my code:
[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.I...
I have a scenario where I'd like to render an ActionLink programmatically, ether from a controller or ideally an extension method. This is so I can wrap up some logic of wether to display the link and remove that logic from my view.
I can create an ActionLink using the MVC Futures project from CodePlex.
ActionLink actionLink = new Acti...
Hello,
I am using .NET 4.0 and the entity framework to do some server side validation. I have a simple table called "Contacts" which looks like this:
ID int Dont Allow Nulls
FirstName nvarchar(50) Dont Allow Nulls
SecondName nvarchar(50) Dont Allow Nulls
MobileNumber nvarchar(50) Dont Allow Nulls
HomeNumber nvarchar(50) Allow Nulls
...
We recently upgraded a project to MVC 2 and we'd like to use Areas but there is an issue.
We have created a new area, setup a controller, configured a route, and created a view in the correct location. When we run the code it successfully finds the route and hits the controller but when it goes to render the view there is an exception....
When I edit my web project references, I can't find the System.Web.MVC2 assembly in the GAC.
That's not what I expected since the Synaptic Package Manager reports that libmono-system-web-mvc2.0-cil package is installed properly.
...
I have a one form tag inside my Index.aspx view. Index.aspx contains several partial views and using the same model to render them.
Now when any partial view is posting the form with submit button form is posted to OneActionMethod. But I want for some partial views to post form to OtherActionMethod.
How can I achieve this, without us...
Hi..
I have an MVC application and using telerik grid for performing the listing,add,edit operation.I am using popup mode for edit/add .I want to show the datepicker for date datatype in the edit and add operation.
I have created a partial view for the datepicker using telerik as:
<%@ Control Language="C#"
Inherits="System...
Hi,
I would like to cache static background images in my APS.NET MVC 2 web page.
What's the best way to do this?
...
I have a model that contains a List<PhoneNumber> property. I use TryUpdateModel in my update actions. Adding new numbers and changing existing numbers works fine. Removing existing numbers, however, works only if I don't try to remove everything. If I remove everything from the list, none of the items get deleted.
I realize that this is...
I'm pretty new to MVC 2 and I'm having problems figuring out how to post values that lies outside the form.
This is my code very simplified:
<input type="text" id="TextboxOutsideForm"/>
<% using (Html.BeginForm("Edit", "Home", FormMethod.Post)) {%>
<%: Html.ValidationSummary(true) %>
<%: Html.TextBoxFor(model => model.Stu...
I have a form(this form is a pop up) in which i have a JQGrid and a set of fields that i want to submit to the controller. The following is part of the form
<% using (Html.BeginForm("Index", "Role"))
{
%>
<tr>
<td>
<%= Html.Hidden("RoleId")%>
<%= Html.Label("Priority:")%>
...
I'm posting a form from a partial view which is rendered via Html.RenderAction and I want after the form post to redirect to the same route from where the request came.
public ActionResult Index()
{
return PartialView();
}
[HttpPost]
public ActionResult Index(FormModel input)
{
...
return //Redirect to the same route
}
...
Hi all, I need to deny all access to any controller if they do not login.
I do not want to do this for each entry:
[Authorize]
public ActionResult AnyMethod() {
...
}
I try something like that but this was denied access to everything (css, js, ...).
<authorization>
<deny users="?"/>
</authorization>
In the Web.config I have on...
I'm using Unity as a IoC container in my MVC2 project, and I was wondering if there was a way to resolve property dependencies inside my filters from a class that extends the DefaultControllerFactory (I've resolved all of the dependencies in my controllers this way). I know I can resolve them by extending the ControllerActionInvoker, and...
I am checking that the ModelState.IsValid in my action method that create the Employee
[HttpPost]
public virtual ActionResult Create(EmployeeForm employeeForm)
{
if (this.ModelState.IsValid)
{
try
{
IEmployee employee = this._uiFactoryInstanc...
Hey guys
I got a problem with a custom ViewEngine. I try to overrite the FindView method to set the master view without having to define it in each and every view page.
public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
{
if (string.IsNullOrEmpty(masterN...
I have been dealing with this for at least two days now. I don't have a book available to reference, and I cannot for the life of me find an explanation of how this is supposed to work.
What I am trying to do is a simple operation:
Load a create form populated with 3 dropdownlist elements which reference other tables
Fill out the form...
What I would really like to be able to do is redefine the conventions to do the following:
For Controllers and their respective Actions:
If a URL request is made, and there is not a controller with the supplied action, then perform some "default" function, which I would supply myself in the application. I would think this could be ach...
I have a form that lets the user enter in some text. It will be longer than a few characters so I want to use a TextArea instead of a TextBox.
The Html.TextBoxFor works without issue, and the Html.TextAreaFor works when I create the entry, but does not store the new value when I edit it and shows whatever the value was before I went to...
I am using the IIS 7 Rewrite module to rewrite an incoming url like:
http://server/year/all
to
http://server/application/controller/year/all
Everything works fine, except when, while processing the rewritten request, I use MVC's UrlHelper.GenerateUrl() method:
UrlHelper.GenerateUrl(
"Assets",
"Css",
"Asset",
new RouteVal...