ASP.NET MVC Ajax helpers block other Ajax requests - asp.net-mvc

I have this very strange problem.
Currently I'm using ASP.NET MVC Ajax Ajax.BeginForm helper.
After it creates successful post request to server and receives response my other components that use ajax, are not able to request anything from server (Firebug just does not display any requests, at the same in another browser window I can get response from server just fine the problem is defiantly not on server side).
But when I return nothing in response to Ajax.BeginForm helper request my other ajax components are able to make requests to server.
Is it a know issue with ASP.NET Ajax or I'm doing something wrong?
Thank You very much!

Your probably crashing the application server with that request. Check your server logs. If your debugging this kind of thing happens, your maybe not catching an exception.

Related

Can we use only HTTP POST and and get rid of HTTP GET?

I am new to ASP.NET MVC. I am using http POST for custom validation. Recently I learned that both http POST and http GET are used to send data to the server. HTTP POST is more secure while http GET is less secure as it sends the data in the query string.
I want to know then, is it possible to get completely rid of HTTP GET in my project as its function is similar to http POST? I tried that but it immediately gave error as soon as I started debugging the project. It said "The resource cannot be found.". I am confused. Please help.
I would recommend to review Http Methods - MDN
Since you just started the right course of action would be to use GET to obtain the data (e.g. load the form) and POST to update the data (submit the form to the server).
If the application you are working on is written in plain ASP.NET MVC it will be impossible to completely avoid GET (as it is used by the browser to load application pages/views).
Once you are ready to move to REST APIs you might want to deeper explore PUT, DELETE and other methods

I'm not seeing any POST requests when I run my Blazor Server App

I'm running a blazor server app that has been deployed to IIS. The site has a REST web service as it's back end. The code is something like this:
<EditForm Model="#boundObject" OnValidSubmit="HandleValidSubmit">
<td>
<input type="checkbox" #bind="boundbject.HasCar" />
</td>
<button type="submit">Submit</button>
</EditForm>
#code {
private void HandleValidSubmit(object handler)
{
if(boundObject.HasCar)
{
webService.WriteHasCar(boundObject.objectID,true)
}
}
}
It works just fine but looking at the network traffic in Fiddler when I submit this request, I can see the PATCH request going to the webService that the call to the web service does, but I'm not seeing a POST request for when I hit the submit button. What am I missing here? Is the Fiddler trace failing to see it or will my code not generate a POST request? And if it doesn't, how is the value of the checkbox getting to the server?
You can't see a Post request because no post request is made. Your form is not submitted. No traditional post request occurs though you're using a submit button.
The submit action is intercepted by Blazor and cancelled, as this is an SPA application with well-defined space boundaries. You usually do not navigate out of these boundaries, and if you do, as for instance, navigating to an external login page, your SPA does not exist any longer. When you are redirected back, it is resurrected...
Server Blazor Apps do not use the HTTP protocol, but rather SignalR. All the communications between the client-side (browser) and server-side of Server Blazor App is perform via SignalR.
Note that the initial request to your App is an HTTP get request. This is the only time HTTP is used and not SignaR

How to invoke/simulate request to any url of application inside of application

How can I invoke a request to any url (controller/action) of my Rails3 application inside of application?
I've tried to use app object (Application) with get method, but it works only from console and not in the application.
For example: I have a controller that could handle all requests. It is not configured in routes.rb and this controller could parse the request.uri and return HTML in accordance of request. I need to get this html inside of application in other controller.
What you are asking for is the component feature that was officially removed from Rails in 2008 because it was slow and leads to bad design practices.
You can try to reproduce the feature, if you really need it. Or you can perform a new HTTP request internally (using a HTTP client) to the second location, get the response and then return the result.

Call Server Side function/event using jquery

How to call a server side function/event using jquery ?
What you are looking for is the AJAX jQuery methods. You can use these to either send a GET or POST request to the server, and the server can process whatever needs to be done server-side and return the results to jQuery. I suggest looking through the jQuery API page I linked to get a better understanding of how AJAX works within jQuery.
To call a server side functionality. You need to understand the concept of Ajax. jquery also provides some of the methods which can be used to make ajax hits.

How to pass data from a web page to an application?

Trying to figure out a way where I can pass some data/fields from a web page back into my application. This needs to works on Windows/Linux/Mac so I can't use a DLL or ActiveX. Any ideas?
Here's the flow:
1. Application gathers some data and then sends it to a web page using POST that is either imbedded in the app or pops up a new IE window.
2. The web page does some services and then needs to relay the results back to the application.
The only way to do this that I can think of is writing the results locally from the page in a cookie or something like that and have the application monitor for a specific file in that folder.
Alternatively, make a web service that the application hits after passing control to the page and when the page is done the web service will return the data. This sounds like it might have some performance drawbacks.
Can anyone suggest any better solutions for this?
Thanks
My suggestion:
Break the processing logic out of the Web Page into a seperate assembly. You can then create a Web Service that handles all of the processing without needing to pass control over to a page.
Your application can then call the Web Service directly and then serialize the results and work with the data quite easily.
Update
Since the page is supplied by a third party, you obviously can't break anything out. The next best thing would be to handle the entire web request internal to your application (rather than popping a new Window).
With this method, you can get the raw HTTP response (and page markup) and work with it directly. You can then parse the Response stream and gather the required data from it.
During performing an HTTP request you should be able to retrieve the text returned by the page. For instance, if your HTTP POST was to hit a Java servlet, the doPost() method would be fired and you would then perform your actions, you could then use the PrintWriter object from the Response object (PrintWriter out = response.getWriter();) and write text back to the calling application. I'm not sure this helps?
The fact that
web page is hosted by a third party
and they need to be doing the
processing on their servers.
is important to this question.
I like your idea of having the app call a webservice after it passes the data to the third-paty web page. You can always call the webservice asynchronously if you're worried about blocking your application while waiting for results from this webservice.
Another option is that your application implements an XML-RPC server that can be called from the web page using PHP, Python or whatever you use to build the website
A REST server will do the job also...

Resources