MVC :: How To Call A Controller From Another Referenced Project
Mar 10, 2011I want to create a base web project which other projects will extend. How can i call the render action on the controller found in the base controller?
View 1 RepliesI want to create a base web project which other projects will extend. How can i call the render action on the controller found in the base controller?
View 1 RepliesI have a C#.net class library that references a folder and the files in it.
I've added this library as a reference in my ASP.NET web project and I can't figure out how i'm supposed to get the path to this folder.
Or would you have to pass the Server.MapPath in from the website?
I have a utility project that has an "XML" folder with two XML files in it, this project is then referenced by an ASP.net web project. I was wondering do you have to set some sort of build option to place the folder in the BIN of the website, or is there another approach to referencing these two files from the web project?
View 1 RepliesI have a Visual Studio 2010 solution consisting of 2 projects:Core, a C# class library project which handles the functionality and data accessUI, an ASP.NET 4 website (.NET Framework 4) that references the Core, and calls functionality in the Core.
My exception handler is set in Global.asax (Application_Error.)When an exception occurs in the UI, everything works perfectly, I get filename, line number, etc.This is not the case for exceptions that occur in the Core.For this, I get a stacktrace like:
{FillUserCount at offset 2376 in file:line:column <filename unknown>:0:0}
P.S. The Core.dll and Core.pdb are present in the UI Bin folder.
In Visual Studio -> Tools -> Options -> Debugging -> "Enable just my code" is unchecked and "Enable source server support" is checked.Is there a way to get stackframe info (filename, class, method, line number) also for errors that occured in my referenced project ?
I'm using ASP.NET on C# and I have a referanced library in the same solution in VB which calls a COM object using CreateObject.When I run the site on my comp it works, when I run it on my IIS 6 it gives me a stackoverflow on the method call.Now I have a script wich runs the VB code on the IIS6 and it works just fine.It must be something with the ASP...How can I call Com objects within ASP..., Do I have to do something special?
View 2 RepliesI have an ASP.Net website, "MyApp", which contains the following resources files:
WebResources.resx
WebResources.es.resx
The website references a library project, "MyLib" from which I want to access those resources files. Here is the code I'm attempting:
var rm = new ResourceManager("MyApp", Assembly.GetExecutingAssembly());
subject = rm.GetString("HelloMessage"); //always string.empty
The problem is that the executing assembly is always "MyLib" instead of "MyApp". Is it possible to access the resource files embedded in the website project from a library project?
How to access proxy class of a web service which has been referenced in the website project of a solution within a class library project in the same solution?
I mean no web-service reference/setting is added to the class library and instead it needs to be picked from the web project.
If I have two projects say Project 1 and project 2 can I have a controller action in project1 redirect to a controller action in project2?
View 1 RepliesI have one problem with actionlink. My Example is: i have one view and controller named as XYZ.aspx and XYZ.vb controller , in this view i put below line
<%=Html.ActionLink("Manage", "Index", "Advertisement", New With {.aintCampaignid = Cam.CampaignID})%>
I have another view and controller named as Index.aspx and Advertisement.vb if click on manage link in XYZ view it will call to advertisement controller and index function But iam getting [URL], it wont call ..
how to page index.cshtml call variable from controller
i using vs2010 & mvc3.0
application has a main controller which gets some requests that should be filtered first. This main controller decides which other controller should handle the request.The redirection is usually possible with RedirectToAction(..). But using this method causes a round trip and changes the original called url. This behaviour is not wanted. The url should e left as it was in the origin request.Is this possible? If yes - how?If i instanciate a controller myself (simple call of new MyConstructor()) and call the wanted action then this controller runs in the wrong context and the views won't be found.
View 8 RepliesI have an asp.net MVC2 application that needs to call a web service from the controller. How do I do this? It is a RESTful service that returns Json data.
View 4 RepliesI am using dotlesscss for my css and I remember how to use that but what I am forgetting is how to get the root project path so that I can generate the full file path to my .less file to get for the less engine to parse. How do I get the project root path so that I can generate the path for my less files?
View 1 RepliesCan I call a webservice from a Controller Action in ASP.Net MVC?
public ActionResult Index()
{
PersonObject person = new Person("Sam");
//Call a webservice which is located in the same app under /Services/General.asmx/WebMethod and pass it person
}
Basically I want to do this from my Action...
$.ajax({
type: "POST",
url: "/Services/General.asmx/WebMethod",
data: JSON.stringify(DTOInternetPricing),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(res) {
},
error: function(res) {
}
});
I'm working on getting a new MVC 3.0 application up and running on a Windows 2008 server, running SQL05 and IIS7 with ASP.NET Framwork 4.0 as well as MVC installed. The index page has two select boxes. Selecting an option in the first select box does an ajax call to my controller that populatest the second select box. This works just fine on my winxp dev machine but returns a 404 on the call to the controller when running
on the server. Code for that call:
<% Html.EnableClientValidation(); %>
<% using (Html.BeginForm("CamperDirectory", "TradingPost")) { %>
Select a Season: <%: Html.DropDownListFor(x => x.SelectedSeason, new SelectList(Model.GetSeasons, "Value", "Text"),"Please select a Season.") %><br /><br />
<%: Html.ValidationMessageFor(model => model.SelectedSeason)%>
Select a Session: <%: Html.DropDownListFor(y => y.SelectedSession, new SelectList(Model.GetSessions, "Value", "Text"), "Please select a Summercamp Session.") %>
<%: Html.ValidationMessageFor(model => model.SelectedSession)%>
<input type="submit" value="Go" />
<% } %>
</asp:Content>
<asp:content ID="Content3" contentplaceholderid="HeadContent" runat="server">
<script language="javascript" type="text/javascript">...............................
How do I call and action/controller from inside a jquery function?
View 3 RepliesI have one problem with actionlink. My Example is: i have one view(xyz.aspx) and controller(abc.vb) , in this view i put below line
<%=Html.ActionLink("Manage", "Index", "Advertisement", New With {.aintCampaignid = Cam.CampaignID})%>
I have another view(Index.aspx) and controller(Advertisement.vb) if click on manage link in XYZ view it will call to advertisement controller and index function But iam getting [URL] it wont call.
I did some service operation in mywcfdataservice.svc Now I have to use the service operation in my controller but I don't find them.I can use:
Entities2Voice context = new Entities2Voice();
and so I can read the table of my db, but I didn't find the way to see sevice operation.I have my model.edmx to use sql db and the code in mywcfdataservice.svc works right. I can call the service operations from my browser and they work.I try to add service reference to my .svc file, to use it as a service, but when I press ok button after some seconds, I take an error (is in Italian):Il documento HTML non contiene informazioni per l'individuazione del servizio Web.I metadati contengono un riferimento che non può essere risolto: 'http://localhost:2873/WcfDataService2Voice.svc'.Il tipo di contenuto text/html; charset=utf-8 del messaggio di risposta non corrisponde al tipo di contenuto del binding (application/soap+xml; charset=utf-8). Se si utilizza un codificatore standard, verificare che il metodo IsContentTypeSupported sia implementato
correttamente. I primi 1024 byte della risposta erano: '
i have an ascx page and it contain certain methods... on click i want to make a jquery ajax call to the controller and call the ascx page methods..
View 3 RepliesAs I call the Controller to exit the focus of my textbox? I need to exit the textbox, go to the database to get information that will supplement the information from my form.
View 2 RepliesI have a mvc controller that communicates with a we service for user authentication, when user clicks login button, onclick event makes a call to javascript function using ajax and it makes a call to an action in server.The problem is when a use fiddler tool shows ajax call to the controller and also web service call, web service is called from controller never javascrit, how I can protect visibility of web service calling?, using web forms with the same scenario never shows a web service call.
View 2 RepliesThis is probably something simple. The following JQuery call is executing and calling the controller. The controller is executing correctly. I used the sample data that's commented out to verify that the templates were working also. However, the success function is not executing in the browser. Any thoughts or other ways I can debug this?
<script type="text/javascript">$(document).ready( function(){ alert("Here"); @* var myData = [ {first: "Jane", last: "Doe"}, {first: "John", last: "Doe"} ]; *@ $.getJSON( "/User/Filter",function(myData){ $("#myDataTemplate").tmpl(myData).appendTo("#itemContainer"); } ); alert("there"); }
);</script>
//Controller
public ActionResult Filter() { var myData = this.repository.GetAllUsers(); //return Json(myData); return Json(myData, JsonRequestBehavior.AllowGet);}
In the view I have a HTML button:
<input type="submit" value="Submit" />
Also I have a dropdownlist, how do I call the controller's action after I click the "Submit" button?
And how do I pass the Model back to the controller action as well?
The reason I want to pass back the model (or other object/class) to controller's action is I might have 5 dropdown lists and 3 edit boxes values to be sent as parameters. So I would like to assign these parameters into a object and send it back to controller's action.
ia ma working on an asp.net mvc 2 app and i have a Users view, displaying all the users of the database. Then, i would like to add the ablility to display "users starting with fisrt name" capabaility on the same view. For this i created a list of all english leters that actually are links (<a href="#">A</a>, etc...)
I managed to handle the click event of each one of the letters and get the corresponding letter via jquery, but i don't know how to call theHttp.Post Users/FindUserByFirstLetterName(string letter) on the click event.
I cannot use the Html.ActionLink<> helper, since it redirects me to the HttpGet controller action.
I also tried using using jqery.Post but i also couldn't manage to call the action.
I'm trying to write a controller method that returns an ActionResult.
In this method, i would like to:
1. call an HTML helper method
2. Capture and store the HTML helper's rendered HTML in a string
3. Return the method with the rendered HTML wrapped as a JSON
How do i call the Html Helper method from my controller method? Simply using the static class HtmlHelper does not work.