NancyFX calls action without request from browser - asp.net

There is smth strange in my NanceFX app.
I've created an "action" for GET request with a name "Load".
Now I just start my application and begin type a url for "load" action and it calls without pressing enter! How is it possible?

Related

Oracle APEX button - link to URL and execute dynamic action

I am working with APEX 20.
I defined a button which links to a URL:
Behavior: "Redirect to URL" and my URL as Target - this works without any problem.
When this button is pressed, I have to change the status in a table in my data model.
I added a Dynamic Action which executes some PL/SQL code to update my table.
The problem is that when the button is pressed, the redirect is done and my dynamic action is
not executed.
Is there any way to change the sequence, executing the dynamic action first, and then the redirect?
Some background:
This application allows users to define + configure systems and queue them for automatic installation. The installation is done from a remote server, and must be triggered by calling a CGI script per URL. When the order is issued, the user should come back to the applications main page to work on other systems.
Therefore I choose a modal dialog to launch the order. The idea is:
On the system page press button "Install"
Modal dialog page opens
Here you press the usual "Do you really wish to install" button (since it will cost money now).
At this moment the status in the database must be altered, and the redirect to the URL must happen.
The modal dialog closes and the user is back on the system definition pages.
I tried to connect the button only with the dynamic action to update the database table,
followed by a "submit" action.
In this scenario I added a branch to the URL to be processed after page submit, which did not
work.
I also tried to intergrate the redirect to the URL into the PL/SQL code using apex_util.redirect_url, but I do something wrong, this part is simply ignored.
What you could try is:
Make the button with action "Submit Page"
Create a page process in the with point "Processing". This is where you'd execute the code to update the table. Add a when button pressed server sided condition.
Create a branch to redirect to the new page after submit with the same when button pressed server sided condition.
This is "the traditional" way of doing it in APEX - handle all database actions after page submit. No dynamic actions are needed in this case.

Redirecting the response on ASP.NET Web Forms DevExpress callback error

We have ASP.NET Web Forms website that uses DevExpress controls. Using the 2nd option on this page https://docs.devexpress.com/AspNet/8888/common-concepts/callbacks/handle-callback-exceptions/redirect-response-on-callback-exception, we implemented redirection to an error page when error happens in a callback request. Note, we cannot use the 1st option (web.config), because error page URL is dynamic.
It works fine, except when the code invoked by the callback contains asynchronous task like so:
RegisterAsyncTask(New PageAsyncTask(Async Function()
Await MyAsyncFunction(arg1, arg2)
End Function))
If error happens in MyAsyncFunction, instead of being redirected to the URL passed to DevExpress.Web.ASPxWebControl.RedirectOnCallback(), the browser shows javascript alert with the error message.
How can I make errors happening in async functions result in a redirect?

How to clear MVC 3 routing parameters on log out

I have an ASP.net MVC 3 app using razor, and when using the default AccountController to log out the current user, I have picked up a security issue. After clicking log out (_LogoutPartial view), I get redirected to Log On page. Fine, but when I click Back on the browser, it allows me back into the web application and does not ask for me to log on.
The route with parameters is as follows:
routes.MapRoute(
"Person", // Route name
"Person/{profileName}/{action}/{id}", // URL with parameters
new { controller = "Person", action = "Index", id = UrlParameter.Optional } // defaults
);
//example http://localhost:1946/Person/JoeBlack/ListTeamMembers
It seems the {profileName} is still active in the session (?) and allowing the call to the controller. However the controller action {ListTeamMembers} has the [Authorize()] attribute, so Im not sure how its letting the user in...
When you press the Back button on your browser, the last page is retrieved from the cache of the browser. The server is never hit. The user is no longer authenticated. This means that if he attempts to perform some action and sends an HTTP request he will be redirected to the LogOn page. The way to prevent this from happening is by excluding all authenticated pages from the client browser cache. You could have a custom NoCache action filter for this job.

Asp.Net MVC routing diffrence in www.Mysite.com/Employee and www.Mysite.com/Employee/ while using JqGrid

I am using ASP.NEt MVC for one of my project.
In this I have Employee controller which can be called by www.Mysite.com/Employee/ url.
Also I have used JqGrid which uses followng to fetch data
url: "GetGridData"
While testing the same I found that
If i type www.Mysite.com/Employee/ in browser a call is made to
www.Mysite.com/Employee/GetGridData
If i type www.Mysite.com/Employee in browser a call is made to
www.Mysite.com/GetGridData
Note: the missing / at the end in second call.
How to rectify this as the chances are end user can type any of this url in browser.
I'd take a look at how you're asking JqGrid to make it's web service call - because it won't know anything about MVC's routing engine by default - and this is all happening client side.
Stepping outside of MVC for a minute, if I have a page:
example.com/page1.aspx
And have a relative link to another page on there:
Click here
The browser will look for page2.aspx at the same level as page1.aspx, i.e.
example.com/page2.aspx
If I move page1 to a new folder:
example.com/NewFolder/page1.aspx
The browser will ask for
example.com/NewFolder/page2.aspx
when a user clicks on the link.
The same thing is happening to your GetGridData call - these are being made by the web browser to your server based on the information it has available to it.
So if your page responds on:
example.com/Employee
And asks for a relative request to:
GetGridData
The browser will send that request to the same level that Employee appears to be on:
example.com/GetGriddata
Which then fails because the routing engine can't find a route for that request.
You should look at generating the URL for the GetGridData call dynamically through the routing system, which will ensure that it's built as:
url: "/Employee/GetGridData"
Final edit to add
Forgot to mention, you should probably use the UrlHelper Action methods for this:
url: <%=Url.Action("GetGridData")%>
This will generate a path to the GetGridData method on the current controller. If you need to access a different controller, or pass some values, there are overloads to help.
Try debugging your route:
Phil Haack's: ASP.NET Routing Debugger

Abort Asynchronous Web Service Call and redirect to another URL (ASP.NET Ajax)

In my webapp, I have a list of links generated from code-behind and bound to a repeater control. Clicking on a link opens a popup window, where, along with displaying some data, an asynchronous call to a WCF Service is made (through a javascript proxy). This service in turn calls another third party web service that might take a long time to respond. I am working with IE6, thats a unavoidable requirement.
Now, I abort this service on onunload if the user decides to not wait for the call to complete and just closes the popup window. The problem is, if the user clicks another link from the repeater immediately after, the new popup window opens but doesn't load the page (doesn't go to the supplied URL) till the previous asynchronous call has completed (I have verified this through Fiddler). Interestingly, this only happens for links within the same domain. If I change the link for one of the popus to, say, www.google.com, then the window opens and goes to the correct url as intended. But, for popups with links within my own domain, which are opened immediately after a popup window with an unfinished request was closed, it waits till the previous request completes before loading the url.
I have verified the correct way to abort a callback and abort does fire properly. I also know that I can only abort my client side call, and not the server side call and I don't care about it. My only requirement is that the browser load the next link regardless of the previous asynchronous response.
//Method to Call Service:
function GetData(Id) {
//call the service
Sys.Net.WebRequestManager.add_invokingRequest(On_InvokingRequest);
var service = new WrapperService();
service.GetData(Id, handleSuccess, handleError, null);
Sys.Net.WebRequestManager.remove_invokingRequest(On_InvokingRequest);
}
//method to get the current requests abort executor
function On_InvokingRequest(executor, eventArgs) {
var currentRequest = eventArgs.get_webRequest();
abortExecutor = currentRequest.get_executor();
}
//abort service on unload
function unload() {
if (abortExecutor != null) {
abortExecutor.abort();
}
}
Helpful/Similar links for the background:
browser-waits-for-ajax-call-to-complete-even-after-abort-has-been-called-jquery
aborting-an-asp-net-web-service-asynchronous-call
canceling-ajax-web-service-call
Anybody faced this before? Its driving me nuts! Any help will be greatly appreciated.
The answer in one of your links sounds like the problem to me:
Browser waits for ajax call to complete even after abort has been called (jQuery)
Does your service require session state?
You could prove whether the problem is that IE itself won't issue the request by configuring IE to allow for more than 2 requests to the same domain. If it's being blocked because the aborted request is somehow eating up one of those connections, then increasing it should yield different results. If it still has the problem, it must be that the server is waiting to respond.
Configure IE for more than 2 requests:
http://support.microsoft.com/kb/282402
Quote from one of the SO questions you linked:
It turns out I was completely wrong about this being a browser issue - the problem was on the server. ASP.NET serializes requests of the same session that require session state, so in this case, the next page didn't begin processing on the server until those ajax-initiated requests completed.
Unfortunately, in this case, session state is required in the http handler that responded to the ajax calls. But read-only access is good enough, so by marking the handler with IReadOnlySessionState instead of IRequiresSessionState, session locks are not held and the problem is fixed.

Resources