I have an HTML form, to which I dynamically add a text field and perform a POST request for that form via jQuery to an ASP.NET MVC controller.
If I invoke the POST request without the ValidateAntiForgeryToken attribute on the controller action, it works fine. But, when I add the ValidateAntiForgeryToken attribute to the action I get the...
I am developing a simple email marketing web application with ASP.NET MVC 1.0. I have setup CKEditor 3.1 on a textarea in a view, the HTML editor renders fine. I can save the HTML content from the textarea with a POST to the controller.
The application needs to provide some "starter" HTML email templates to users for preparing an email...
Is there any way to get the explicit role that a user belongs to in my controller? This assumes using ASP.NET Membership and Role Providers. "IsInRole" doesn't work - I need to actually get the name of the role they are in.
...
Say I want to display user details like so:
http://www.mysite.com/user/1
I set a route up like so:
routes.MapRoute("UserDetails", "user/"{id}",
new { controller = "User", action = "Details" });
Then my controller:
public ActionResult Details(int id)
{
User currentUser = _userRepository.GetUser(id);
if (currentUser == nul...
This seems to be a pretty trivial problem that I have been stuck on for about an hour, and I don't understand what I'm doing wrong.
I have a ViewModel:
public class SongFormViewModel
{
public Song Song { get; set; }
public SelectList AlbumList { get; set; }
public SongFormViewModel(Song song, IQueryable<Alb...
First check the slide that is referenced here: http://weblogs.asp.net/leftslipper/archive/2007/12/10/asp-net-mvc-design-philosophy.aspx
Since I have been using ASP.NET MVC I have in my mind conceptually been aware of the 'URL Routing', 'Controller', and 'View' stages that are shown here...
But what is meant by all the other stages? Can...
Say you have this:
public class ShoppingCart {
public IList<CartItem> cartItems {get; set; }
}
And you do this to render the class:
<%= EditorFor( m => m.ShoppingCart, "ShoppingCart") %>
How would you do the EditorFor( ??, "CartItem") in the ShoppingCart.ascx? I would think it would look something like this:
<% foreach( CartI...
I'm been working on a GetRuleViolations() method for my User class, but I'm getting a little hung up on on something:
What happens when different actions require different business rules?
My User table has the following columns: Id, UserRoleId, Username, and Password. Several actions involving User are possible (create new user, edit u...
Hi
I have two strongly Typed partial views (Developers list and Testers list) and the respective views are Developers.ascx and Testers.ascx
Now I want to load one partial view based on the radiobutton selected.
How to read the value of the radiobutton option?
I would appreciate if anyone can provide Code snippet or some guidelines.
A...
I want to generate complete Url (with domain name etc) of any file in MVC. Example: A .jpg file or an exe file.
Example: If I give "~/images/abc.jpg" it should return "http://www.mywebsite.com/images/abc.jpg"
I am aware of the Url.Action overload that takes the protocol as a parameter. But Url.Action can be used only for Actions.
I wa...
i wrote this script
$.getJSON('<%=Url.Action("JsonSave","Controler")%>',
{ id: newRow.Id, personId: newRow.PesronId},
function(data) {
$('#grid').trigger('reloadGrid'); //{0}
$('#grid').editRow(rowCount); //{1}
})
what should i do so that {1} would be executed exa...
I have a public facing hobby site that gets about 3000 unique visitors a day, written in classic ASP that is in bad need of a revamp and redesign. I've faced the realization that an upgrade to ASP.net is the best way to go to implement features that are just too hard in ASP for the hobbyist (consuming RSS feeds, authentication and user ...
How come there are a lack of Controls for ASP.NET MVC?
Sure it hasn't been around that long but one would think that a GridView, Calendar and other important controls would be included or at least in seperate packages.
However, I've failed to find any besides the ones that cost a lot of money for nearly nothing at all.
Does these type...
Hi,
We have created a custom membership provider that we are using in one of our applications and now I would like to use the same provider for all our applications so that you only have to login once and stay logged in when you switch between applications.
Just by using the same provider in web.config for different applications doesnt...
the problem is that if the auth cookie has expired and the user clicks on a link that should open a popup using $.get than i get the login screen in the popup (same masterpage in another masterpage) instead of redirecting the whole page to the login screen
anybody knows how to fix this ?
...
For example, if i use this in view:
${Html.TextBoxFor(u=>u.UserName)}
How can i
var name = [xxx].NameFor<User>(u=>u.UserName);
from elsewhere? Is that possible?
...
This seems like a really silly question, but I've had a search around and I can't find anything about this.
I've got a DB connection string that I'm creating in my web.config:-
<connectionStrings>
<add name="DBConn" connectionString="Data Source=<db svr>;Initial Catalog=<dbname>;Integrated Security=True" providerName="System.Data.Sq...
Is there an easy way to get the MvcRouteHandler to convert all hyphens in the action and controller sections of an incoming URL to underscores as hyphens are not supported in method or class names.
This would be so that I could support such structures as sample.com/test-page/edit-details mapping to Action edit_details and Controller tes...
I'm writing a unit test and I call an action method like this
var result = controller.Action(123);
result is ActionResult and I need to get the model somehow, anybody knows how to do this ?
...
I have a controller decorated with an AuthorizeAttribute. The controller contains several actions that all require authentication apart from one action that requires some custom authentication provided by CustomAuthorizeAttribute.
My question is once I've added [Authorize] at the controller level can I override it (or remove it) with [C...