MVC :: GetJson Not Called In A Web Application?

Apr 13, 2010

I am trying to make my ASP.NET MVC 2 application working from a test server.

Since I am using IIS 6 in my test server, I have to define in the Global.asax.cs file:

"Default", // Route name
===> "{controller}.aspx/{action}/{id}", // URL with parameters
controller = "Home",
action = "Index",
id = UrlParameter.Optional
} // Parameter defaults

This complicates the correct definition of the URL in my getJson() calls for my site production version.

When running my site from the test server, I found using Fiddler that the URL reguested by the browser

for getJson() calls is:

/Controller.aspx/Controller Method

which is correct, but probably, not the complete necessary path for getJson() to work.

I think that this is the reason for getJson() calls to give "Page Not Found(404)" in Fiddler and a syntax error in FireBug and to be skipped completely when trying to execute. Of my understanding the complete path should be:

/My Site/Controller.aspx/Controller Method

I use jQuery 1.4.2.

View 5 Replies

Similar Messages:

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

MVC :: Set Values Into Textboxes Using $getJson?

Mar 23, 2010

I am new to Jquery , i have a problem with setting values in to textboxes when iam using $getjson . here return type is arraylist

My code::


View 11 Replies

C# - SQL Connection In An Application Should Be Called?

Aug 24, 2010

I have an application written in c# and I am using the sqlClient to connect to database. I have several methods and I usually open the connection in a try catch block

**open connection**
//Do something
**close connection**

View 3 Replies

JQuery Function Called Over And Over In MVC 2 Application?

Jan 6, 2011

I want to call an action method when an textbox gets focus to get a description of the model object that field is associated with from a database.

I have this jQuery function:


It works fine as far as getting the test text, but the problem is if I set a breakpoint in the action method, I see that it gets called over and over, not just when i change focus in the text boxes...

View 1 Replies

Web Forms :: Why Page_load Is Called Twice In Web Application

Mar 29, 2010

Initially in my website page_load for the landing page say test.aspx was called twice everytime when it was getting loaded. Since my application is an upgraded one (from VS 2003 to VS 2005/2008), I commented the "this.load" event in InitializeComponent and it is working fine, when user first logs in, into my web application. But then, whenever user navigates to this page from any other page in my application, page_load gets called twice.

View 9 Replies

MVC :: Getting Cascading Dropdown Values Slowly When Using $getjson?

Mar 21, 2010

Getting cascading dropdown Values slowly when using $getjson?



View 7 Replies

C# - Called Generated Web Test Code From Console Application?

Feb 16, 2010

I had a general question about extracting code from a visual studio web test. I used the "generate code" option of a web test and got the following:


What I wanted to do is basically put this test into a separate service to run throughout the day for purposes of health checking. I basically want to make sure that users are able to log in throughout the day. What process should I use to get the test into something like a console app? I was running into issues with debugging the webtest code.

View 1 Replies

MVC :: Application_start Event Called Multiple Times In Application

Sep 15, 2010

In my MVC application ,I am updating my web.config at runtime through application_start event.So, ideally it should be done only when the application is started.BUT in MY mvc application the application_start event of global.asax is being called multiple
times , even when i have not restarted the application.

Its being repetadly called when i am calling different actions , so the webconfig is repetedly updating & making my application very very slow. what's the reason & how to handle this .

View 2 Replies

How Many Times Does HttpModule Init() Method Get Called During Application's Life

Jul 30, 2010

Web application initialization is as follows:

As we know when IIS receives the first request for a particular application resource, IIS creates an instance of a HttpApplication (defined in global.asax codebehind).When this new instance is created it's initialization happens that also checks all configured HTTP modules.All modules are then instantiated and put in the application's Modules collection (of type HttpModuleCollection)modules are looped through and their Init() method is called (when they register for request events)

As far as I understand it the above scenario happens when a web application is started/initialized (hence application start event).What happens with modules?

Are they (re)instatiated on each request or reused from the Modules property on each consecutive request while the web application is alive? As I understand IIS and they are reused through the whole life of a web application.

If they are reused, can we assume that their Init() method is actually a pseudo event handler for application start event? The thing is we can't attach to application level events within http modules. But if they are being reused we could use Init() as application start event and do whatever we'd put in global.asax instead.

Question,Can we assume that module's Init() method is called only on application start event? Could we use this assumption to i.e. register routes for applications whose global.asax codebehind we can't change? web.config is usually accessible and we can change it the way we want.Would this actually work?

Additional info,We can check HttpApplication code and check its InitModulesCommon() method. This one actually calls Init() of each registered HTTP module. What is more interesting is that this method is only used by InitIntegratedModules() and InitModules() methods. Which are both used only in HttpApplication.InitInternal() method. This is the basis of my assumptions, but I would like to know whether someone has abused IHttpModule.Init() for application start event.

View 3 Replies

$.getJSON Back Button Showing Jason Return Data Not The Page?

Jan 10, 2010

I have a little issue with my site. I have a page that hosts a google map. However the map does not get shown until the user clicks a button. It then call $.getJSON to get the addresses that i need to show on the map...

$.getJSON(theurl, function(json) {

It all works fine. However if the user then moves to a different page and then clicks the Back button they get the data from the $.getJSON call displayed, not the page itself. It's as if the call to get the addresses has become part of the browsing history. If the user hits refresh when the data appears the full page then gets displayed.Can anyone tell me how to stop this from happening.I'm using the googlemap in an ASP.Net MVC site.

View 1 Replies

Web Forms :: How Do You Obtain The Absolute Web Application Path In Class Called From A Referenced Dll In A We...

May 1, 2010

I have a class (.cs) in my web application project called CompanyResponseInfo.cs. This class inherits from a class called, ResponseInfo.cs, which is from a class library which is referenced as a compiled dll in the web application. CompanyResponseInfo is called from the ResponseInfo base class. In the CompanyResponseInfo class I need to build a file path to a file that resides in the directory 'web root/resources/standard.xslt'.

Now i know that because CompanyResponseInfo is instanciated from within the inherited ResponseInfo class from a referenced library, the 'System.Web.HttpContext.Current' object is null so I cannot gain access to MapPath and all the other Server object properties for me to obtain path properties relating to the web application.

I have also tried using 'System.Web.Hosting.HostingEnvironment.MapPath' which did work locally, but when I put the web application on our test IIS server it never worked correctly as it seemed to use the path in which IIS resides.

I guess this would be a common problem, so what are my options in my case when I need to get the absolute web application path so I can use it to get the absolute path for a XSLT file so I can load it into the XslCompiledTransform.Load()?

View 3 Replies

How To Tell Who Called An HttpHandler

Sep 10, 2010

How can I tell from within an ASP.NET HttpHandler if it is executing because of a call to Server.Execute("myHandler.ashx")or because of the user linking directly to myHandler.ashx? (Besides using a querystring parameter).

View 2 Replies

Session Being Called Only Once?

Mar 22, 2011

i read that whenenver you call an instance of the your site the session_start is called. I am using the following code to create a visitor counter

void Application_Start(object sender, EventArgs e)
// Code that runs on application startup
Application.Add("Myvariable", 0);


Hence when I run the program the output is "User No:1"

and i copy the url to another firefox tab and paste it there the output is still the same. Isnt it suppose to increment. My session _start is not being called why ?? I was reading a tutorial in which it is being incremented.

View 2 Replies

MVC :: Binder Not Being Called?

Oct 31, 2010

The following code is executed when my app starts

ModelBinders.Binders.Add(typeof(StringValidator), new StringValidatorBinder());

StringValidatorBinder implements IModelBinder and simply throws an exception on BindModel, and I have a break line on there too. So, why does the following post method set "validation" to null and not call my model binder?[HttpPost]public ActionResult Create(string code, string description, StringValidator validation) {......}

View 5 Replies

When Would InitializeCulture Be Called?

Apr 1, 2010

found many pages of my maintence website inherits a base page which overrides InitializeCulture to customize some globalization settings. Is this method called everytime for any incoming request

View 1 Replies

Application_Start() Gets Called More Than Once?

Jun 9, 2010

I have an application made on mvc 2 and it is on IIS 7.5 on my pc I tried profiling it and I noticed that Application_Start gets called more than once, anybody knows why is this happening ?

View 1 Replies

Web Forms :: When Is Application_BeginRequest Called?

Sep 2, 2010

I have two versions of a website. One runs on IIS server on a local PC, the other runs on the ASP.NET development environment included on Visual Studio (localhost). Apart from that, the file stucture of both is the same, although only the one running on IIS works properly, and this seems to be related to the fact that the IIS version calls Application_BeginRequest() where the other doesn't.

I've looked at the differences between IIS server and the ASP development environment in: [URL], and it says that IIS and the ASP development server deal with static content in that for IIS in that on IIS static content does not go through the ASP.NET runtime like it does on the dev environment (but I'm not sure exactly what this means).

I've done a number of tests involving images, etc, and have noticed that when the image is of the form:

<img src="Image/MyImage.jpg...>

the IIS server version calls Application_BeginRequest(), but the visual studio development environment version doesn't.

However, if I change the above code to use:

<img src="<%=ResolveUrl("~/Image/MyImage.jpg")%>" ...>

it will call Application_BeginRequest().

In my case, it is necessary to call Application_BeginRequest because this creates a new path and calls

The problem occurs when using links such as <a href="..." ...>, because if I use static content it won't call Application_BeginRequest() and the path won't be re-written. But If I change it to href=" %=ResolveUrl("~/...")%>" (for some reason, it will only call BeginRequest() if the path begins with a tilde ~), the path is re-written incorrectly.

I'm not really sure how to find out why the IIS version is calling Application_BeginRequest() from all the time (the callstack just says "external code"), or why it is calling it whereas the local dev server version isn't.

If anybody can explain this, or knows of any sites that go into this so I can master the basics, I'd be very grateful.

View 6 Replies

How To Know If A Program Is Called Code Behind

Aug 11, 2010

In my office I am the only Web Developer. There are no other Web Developer.

I was confused by my co-worker programmers regarding the meaning of Code Behind. They told me there is no such Code Behind.

highlight which is CodeBehind from these 2 sets of sample coding:

these are from HTML


Of the 2 sets of sample cpding which one is called CodeBehind ?

View 2 Replies

VS 2008 OnKeyPress Not Called + JS?

Oct 22, 2010

<asp:TextBox ID="TextBox1" runat="server" onKeyPress='return maxLength(this,"30");'></asp:TextBox>

function maxLength(field,maxChars)
if(field.value.length >= maxChars) {
alert("more than " +maxChars + " chars");
return false;

When I Press any Character , maxLength function is not called,WHy SO?

View 5 Replies

C# - Determine Which Tab An Action Was Called From?

Aug 27, 2010

The page I'm editing had three tabs, each tab contains a diffrent grid view which is populated by a search box with in the tab. Each row in the grid view has a check box. When a print button is pressed all records with a tick in the check box should be printed off. Then page then reloads but some of the content is missing due to the way the page has been coded. This is becuase some of the code is only called when the tab is clicked not on postback. Is there anyway that I change the following code so that it's called after postback? These are the functions that are causing the most problem.. I need them to be loaded for the correct tab on postback.. I can't do it for all three as the code takes forever to run in that case.

if (tabconConsignments.ActiveTabIndex == 0)
dtGlobalIDConsignments = fGenerateTableSQL(astrPalletIDs, DateFrom, DateTo, ddlReqColDel.SelectedValue, "GlobalID", "", "");
//Global ID Tab
gvGlobal.DataSource = dtGlobalIDConsignments;
else if (tabconConsignments.ActiveTabIndex == 1)
dtCreatedDateConsignments = fGenerateTableSQL(astrPalletIDs, DateFrom, DateTo, ddlReqColDel.SelectedValue, "CreatedDate", "", "");
//Created Date Tab
gvCreationDate.DataSource = dtCreatedDateConsignments;
tbCreationDateSearch.Text = "";
else if (tabconConsignments.ActiveTabIndex == 2)
dtAccountsConsignments = fGenerateTableSQL(astrPalletIDs, DateFrom, DateTo, ddlReqColDel.SelectedValue, "Account", "", "");
//Account Tab
gvAccount.DataSource = dtAccountsConsignments;

if you want me to post any more code or any more info it's been a hard one for me to get my head around so I might of missed something out.

View 2 Replies

Why Is IHttpAsyncHandler Being Called Over IHttpHandler

Apr 13, 2010

I made a custom handler that derives from MvcHandler. I have my routes using a custom RouteHandler that returns my new handler for GetHttpHandler(), and I override ProcessRequest() in my custom handler. The call to GetHttpHandler is triggering a breakpoint and my handler's constructor is definitely being called, but BeginProcessRequest() is being called on the base MvcHandler instead of ProcessRequest().

Why are the async methods being called when I haven't done anything to call them? I don't want asynchronous handling, and I certainly didn't do anything explicit to get it. My controllers all derive from Controller, not AsyncController.

I don't have the source code with me right now, but I can add it later if needed. I was hoping someone might know some of the reasons why BeginProcessRequest might be called when it's not wanted.

View 1 Replies

Application_BeginRequest Called For Images?

Jul 23, 2010

I've seen a few posts about Application_BeginRequest, but non seems to have my problem.

My Application_BeginRequest is being called for every image in my website.

The StaticFile Handler is enabled with * as the Path, but it's at the end of the list.

Is this the normal behaviour? Or should I add .gif, .jpg and so on on top of the list?

This is on my IIS7.5 Win7 Development Server. Didn't check it on the production server yet.

Setting runAllManagedModulesForAllRequests=false would help. But then the ASP.NET URL Mapping does not work anymore. I tried disable it just for the image directly, but that had no effect?

<location path="Resources">
<modules runAllManagedModulesForAllRequests="false">

View 1 Replies

Executing Only The Last Function Called?

Feb 22, 2010

This is the setup in short. I have a big table. Everytime a cell get focus an asyncron call to the server is done (with PageMethods) and some data is returned and updates a infobox in the page.I have written code that makes it possible to navigate between cells with the arrow keyes.

The problem occurs when I shift focus fast through several cells in order to get to the cell I want. Every get-focus is executed and since the communication with the server takes about half a second it get quite irritating and not very user friendly.Ideally I would like to execute only the last focus event. But how? I cant know which event is the last one, can I?

View 2 Replies

AJAX :: How To See When DataBind Is Called

Dec 6, 2010

I have a user control with cascading dropdownlists. When I populate the controls in the Page_Load event, the second dropdownlist has duplicate entries. These controls are inside AJAX UpdatePanels and I need to find out when DataBind is called on the second dropdownlist to see why it is being called twice.

I am using a SqlDataSource with a ControlParameter to populate the second dropdownlist, not doing it through the code behind.

Is there a window in Visual Studio 2008 that will let me see when DataBind is being called?

View 4 Replies

Copyrights 2005-15, All rights reserved