MVC :: How To Check In Controller Where The Maproute It Was Called

Nov 29, 2010

This two maproute maps to the same controller, how to check in the controller which maproute it was called from?

routes.MapRoute( _
"Categories", _
"category/15", _

[code]...

View 5 Replies


Similar Messages:

MVC :: Controller Not Called From Actionlink Or RedirectToAction

Mar 4, 2011

I am new to MVC2 and have hit a wall. When I use an action link to jump back to a previous page that I have already been on, my controller is not called but the page is rendered correctly. Is this some sort of caching that I am not aware of? This also happens with a RedirectToAction call from another Controller. rfm is the Model...

return RedirectToAction("Search", rfm);

Here is the actionlink...

<%: Html.ActionLink("Search", "Search", "Reference")%>

View 3 Replies

Controller Method Not Always Called From $.getJSON Request?

Mar 9, 2010

I have a controller method that returns a jSON object and in one calling situation, it works and in another calling situation, it does not work. When the URL in my browser is this:

http://localhost:65247/Client -- it works.

But, when my url looks like this:

http://localhost:65247/Client/UserAdmin?id=6 -- it DOES NOT work

In a nutshell, clients have users. From within the client, I wish to work on a specific user (this is the UserAdmin view). In this case, the client id is 6. From within the UserAdmin view that was launched with Id=6, I then wish to select a user from a dropdown. The idea was to use javascript and $.getJSON to fetch data for the specific user so as not to have to refresh the entire page. I use this approach in other parts of the app. The only difference I can see is with the URL in the browser. It would appear the presence of parameters via the '?' is futzing things up a bit.

View 1 Replies

.NET MVC Controller FileContent ActionResult Called From JQuery?

Feb 10, 2010

I have a controller method "SaveFile" that attempts to download a binary stream to client's PC using the FileContentResult. If I make the call as a post from the controller corresponding view everything works OK. I want to call the same controller method "SaveFile" from a jquery function via an .ajax call, when I do the function returns an error and the responseText is the contents of the file to be written. What would I have to do to get the same behavior from a jQuery function as if the MVC framework handled the call via the submit button? Or an alternate solution would be to determine how can I catch the browser's download dialog close event.

View 1 Replies

MVC ::Session Variables Called From The Owning Controller?

Feb 19, 2011

I'm calling an action from another controller using this code

[Code]....

But inside "ApproveOperation" action, I needed the Session variables. It seems when I called it from another controller (not the owning controller), the Session variables can not be accessed (null value).How can I get the same Session variables just like it was called from the owning controller?

View 4 Replies

MVC :: Can't Reach Controller - Javascript Library And Method Called From View

Jul 23, 2010

I have a javascript library and in there i have a method that is called from my view. Here it is:

<li><a href="javascript:void 0" onclick="deleteAll('image', '<%= ViewData["FileGroupId"]%>')"><div><%=GetGlobalResourceObject("default", "Delete_all") %></div><div></div></a></li>
and here is my js code in the javascript library:
var deleteAll = function(module, groupId) {
jConfirm(_deleteConfirmAll, _deleteAll, function(r) {
if (r) {
showProgress();
$.ajax({
cache: false,
type: "POST",
url: _baseUrl + "/" + module + "/deleteall/" + groupId,
success: function(msg) {
if (msg == '0') {
location.href = _baseUrl + '/' + module;
}
else {
jAlert(msg, _errorTitle);
}
hideProgress();
}
});
}
});
}
My problem is that i cant reach my controller. Here is my controller code:
#region common methods
List<.CMS.Core.File> GetList(int groupId)
{
List<CMS.Core.File> list = new List<CMS.Core.File>();
CMS.Core.FileFilter filter = new CMS.Core.FileFilter();
filter.GroupId = groupId;
int res = CMS.Core.File.Search(_connection, filter, ref list);
return list;
}
#endregion
public ActionResult DeleteAll(int groupId)
{
List<CMS.Core.File> list = GetList(groupId);
foreach (File item in list)
{
item.Delete();
}
return Json(list);
}
And at last her is my Index method
public ActionResult Index(int? id)
{
if (Request.IsAjaxRequest())
{
JsonPaging paging = new JsonPaging();
int offset = 0;
int page = 0;
if (!String.IsNullOrEmpty(Request.QueryString["page"]))
{
Int32.TryParse(Request.QueryString["page"], out page);
}
if (page > 0)
{
offset = (page * paging.PageSize) - paging.PageSize;
}
FileFilter filter = new FileFilter();
filter.Deleted = false;
filter.MaxRecords = paging.PageSize;
filter.Offset = offset;
if (!String.IsNullOrEmpty(Request.QueryString["keywords"]))
{
filter.FilterType = FilterTypes.AND;
filter.Name = Request.QueryString["keywords"].ToString();
}
if (!String.IsNullOrEmpty(Request.QueryString["sort"]))
{
filter.OrderBy = Request.QueryString["sort"].ToString();
if (!String.IsNullOrEmpty(Request.QueryString["direction"]))
{
filter.OrderBy = filter.OrderBy + " " + Request.QueryString["direction"].ToString();
}
}
if (id > 0)
{
filter.GroupId = id.Value;
}
List<CMS.Core.File> items = new List<CMS.Core.File>();
int results = CMS.Core.File.Search(_connection, filter, ref items);
foreach (CMS.Core.File current in items)
{
JsonItem item = new JsonItem();
item.Id = current.Id;
item.Name = current.Name;
item.ImageText = current.ImageText;
item.Aperture = current.Aperture;
item.TakenOn = current.TakenOn;
item.Camera = current.Camera;
item.ExposureTime = current.ExposureTime;
item.FocalLenght = current.FocalLenght;
item.Tags = current.Tags;
item.Url = current.Url;
item["Active"] = current.Active.ToString();
item["Created"] = current.Created.ToString();
paging.Items.Add(item);
}
return Json(paging, JsonRequestBehavior.AllowGet);
}
else
{
ViewData["FileGroupId"] = id;
return View();
}
}

View 2 Replies

MVC :: Controller Base Class Initialize() And OnActionExecuting() Not Called When Unit Testing?

Nov 16, 2010

I'm using a simple base class for my controller that sets a piece of ViewData and makes use of the HttpContext. My understanding is that I need to put this code in Initialize() or OnActionExecuting(). I tried both, but believe Initialize() is what I want.

This works when running the app in VS just fine.

I wrote a unit test that calls the action and checks the ViewData for the expected value. When unit testing, neither method is called.

View 2 Replies

MVC :: MVC 2 Area MapRoute?

May 12, 2010

My routes work in the Global.asax, but I created an Area called Dashboard and while it works with the default route, it doesn't when I implement the T4MVC route.

Here's my Dashboard Area Registration class:

[Code]....

If I view this in a browser with the above settings, any Html.ActionLinks render as empty strings, no routing at all.Here's the rendered HTML from the route.

[Code]....

View 8 Replies

MVC :: MapRoute - Specifying A Namespace?

May 6, 2010

What is this namespaces argument for? It seems to have no impact at all. I have two controllers called ClientUser in seperate namespaces of the same assembly. I specify told the route to look in the *.ClientUIControllers namespace and all I get back is:Multiple types were found that match the controller named 'ClientUser'. This can happen if the route that services this request ('{controller}/{action}') does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter.

The request for 'ClientUser' has found the following matching controllers:
RWA.Web.AdminUIControllers.ClientUserController
RWA.Web.ClientUIControllers.ClientUserController
To be clear I am not actually passing MapRoute the namespace but am instead setting this after the call:
route.DataTokens.Add("namespaces", new string[] { controllersNamespace });

I tried to debug MVC2 but it all got a bit too abstracted and with annoying limitations of debugging release build it got too hard. I got up to ControllerTypeCache.GetControllerTypes but I couldn't follow it. I can see that the specified namespace was definiately in the namespaces arg.

View 3 Replies

C# - How To Modify MapRoute (add New Dir)

Mar 26, 2010

How can I change my map route so I can have another dir, and not just the controllers and actions.What I want is to have another directory before the controller so that way I can separate controller per "module"

routes.MapRoute(
"Default", // Route name
"{module}/{controller}/{action}/{id}", // URL with params
new { module = "module", controller = "controller", action = "Index", id = ""}

This is what I want, but the code doesn't work. What more do I need to change to change the MapRoute?

View 2 Replies

MVC :: What Is MapRoute Namespaces Parameter

May 19, 2010

ASP.NET MVC's MapRoute method has a parameter named namespaces. From looking in the code, I see that this parameter is saved in the Route object

in DataTokens["Namespaces"].

It seems to me that it has some meaning... anyone knows what is it for?

View 2 Replies

MVC MapRoute Not Routing With Required Parameter

Jan 26, 2011

I'm wanting the URL to my MVC application to be like:www.site.com/BobWhich would in turn 'redirect' to Home/Details/Bob.I've set up the following MapRoute:routes.MapRoute( _Nothing, _"{personName}", _New With {.controller = "Home", .action = "Details", .personName = ""}, _
New With {.result = New NameConstraint()} _

View 1 Replies

MVC :: 2 Route Map Tutorial: AreaRegistrationContext.MapRoute()?

Mar 30, 2010

As I was trying to create an MVC 2.0 application and map nested areas, I ran ran into a lot of issues mapping routes. So, after I troubleshot all of the bugs, I decided to make a screen cast.Solution Files can be access here: MVC 2.0 AreaRegistrationContext RouteMap Demo Solution FilesVideo tutorial of how to Map Areas.[URL]

View 3 Replies

MVC :: MapRoute Does Not Match Other '-'s When '-' Is Used As A 'path Separator'?

Apr 15, 2010

I have registered the following SEO friendly route:

[Code]....

Anyone an idea how to fix this problem? Returning a 404 is not a nice UX when (in our case) only the id really matters ...

View 7 Replies

C# - Using Grasp Controller With MVC Controller - How To Make An Object Always Visible For A Controller

Dec 28, 2010

UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development, that follows the UP(Unified Process). It uses a Grasp Controller pattern to interact with domain classes by some methods like NewSale(), AddNewItemToSale() and CloseSale. In windows form, I can instantiate a object of this class in the UI and then use its methods to perform the actions. This works well in Client apps, but when I use asp.net mvc, I cannot find a way to instantiate an object (one for each user) that was always visible for a Controller (MVC). I cannot insert as an attribute inside Controller because it always create a new one.

View 1 Replies

User Controls :: How To Check If User In User Account Table Is In Another Table Called UserFollow

Apr 27, 2016

I want to check if a user in User table is found either in UserName Column or in FriendUserName Column in UserFollow table and if yes display lable found, But if no display lable notfound. This code will be excuted onse a user logs in the connection code

protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserName"] != null && Session["UserName"].ToString() != string.Empty)
{
string userName = Session["UserName"].ToString();
if (!this.IsPostBack)

[code]...

View 1 Replies

MVC :: Out Of The Box MVC2 Controller / Delete Controller Is Refusing To Return Any Class Information

Nov 6, 2010

my MVC2 delete and only my delete controller is refusing to return any class information. Its really similar to my edit function and the views are all auto-generated so I don't see the problem.

Function Delete(ByVal id As Integer) As ActionResult

View 4 Replies

MVC :: Pass Parameter From Controller To View And Back To Another Controller?

Aug 16, 2010

I have a simple model where a Person has Gifts. I have a view which is a list of Gifts belonging to one Person.

My problem is with the Create action for a new Gift. I want it to default to the PersonID that we are already viewing the list of Gifts for. I tried simply passing the last PersonID (they are all the same)

Html.ActionLink("Create New", "Create", new { id = Model.Last().PersonID }) which works fine if there is already at least one Gift for that person but if this is the first Gift I don't have a value.

My Gift List controller knows the PersonID I want to pass but the view doesn't.

How do I pass this PersonID from my Gift List controller to my Gift Create controller via the Gift List view? Or is there a better way to do this?

View 2 Replies

MVC :: Session Vs TempData / How To Persist Values From Controller To Controller

May 30, 2010

I have a filter on my MVC web site. I display some records in a few different controller actions but when moving from one action to another I want to apply those filter values.

How can I persist values from controller to controller?

Should I use Session? TempData?

I am using Structure Map for IOC.

Maybe I could have a class that contains a Property for each Session Value that I use in my application and inject it on the controllers that need session?

View 10 Replies

MVC :: Get The Current Action / Controller Name In A Controller Or Class?

Mar 14, 2011

How do you get the current action / controller name in a controller or class?

i can't show it in my view but that's not what i want.

View 1 Replies

MVC :: C# Controller Works, VB Controller Doesn't ?

Jul 22, 2010

C#: HomeController.vb: works fine HttpPost RsvpForm gets the object filled with user input.

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using RsvpInC.Models; namespace RsvpInC.Controllers{ public class HomeController : Controller { //
[code]...

View 5 Replies

MVC :: Calling Action Of A Controller From Another Controller?

Jan 24, 2011

I have a User entity and a department entity. I have a UserViewModel and DepartmentListModel which has List of departments.

UserViewModel has a property of type DepartmentListModel .

Now on user/create action I need to populate DepartmentListModel by calling DepartmentController's list action. List action returns populated DepartmentListViewModel.

From UserController how do I set DepartmentListModel ?

I tried doing so

[Code]....

But RedirectToAction returns RediretToRouteResult

View 7 Replies

MVC :: Area Controller To Inherit "Shared" Controller?

Mar 11, 2010

Say I have several Areas that are baed on user roles.Differnet roles have different functionality, but also have some "shared" functionality like say "Payments"Now, I created a PaymentController (and it's views for listing, creating messages) in Shared (not an area) and it works fine.

Would it be possible (and how?) to create a PaymentsController class in one of the Areas, have that inherit the PaymentController Class in Shared?

If I can do this, I can successfully share common functionality across areas, and at the same time extend the derived controller to include some 'area specific' functionality to common shared controllers. (Such as the "REturn to xxxx" text and route of the returnurl, which are a bit more complicated than I just made it sound)

View 3 Replies

Forms Data Controls :: Update A Date Field When Check Box Check In Detailsview

Jul 15, 2010

I have a detailsview with an update button one of the update fields is a checkbox which when is checked I want to automatically update a date field of when the checkbox was checked, am I going the right way with this code....... as I am getting a number of errors

Dim i As Integer
For i = 0 To detailsview2.Rows.Count - 1 Step i + 1
Dim row As GridViewRow = GridView1.Rows(i) [code]....

View 4 Replies

Forms Data Controls :: Uncheck And Check The Check Box Inside Gridview Using Button?

Nov 12, 2010

i have a UP and DOWN buttons ouside a gridview and a checkbox inside the templated field .I will check the checkbox to sleect a row , after that if i click on UP button the checkbox above the selected checkbox should be selected.

same with when i click on DOWN button the checkbox below the selected checkbox should be selected.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved