I have an MVC app and my action should received a HttpPostedFileBase in parameter. I am trying to understand how the parameter could be null.
It happens time to time in my production environment and I can't figure out the reason.
Related
Assalamu alaykum. I did an API controller. When I run in the visual studio and query, the swagger returns 500 errors, but when I debug it doesn't reach the controller action.
This is why and how to fix it?
I also create a simple, no parameter, just a test endpoint that simply returns an int variable. Any method inside this controller file is not reached when this controller's endpoints are queried.
By the way, this is a .NET framework application.
Knowing brothers #help
I found why this happened. It is because the service used in controller is not registered in DI container. In my opinion, it should just throw an exception instead of returning 500 without reaching to controller action. Anyway, I don't know why, but this worked for me after I added the service to DI.
I actually forgot about this question of mine. But, anyway, there may be something useful for someone in this answer.
I found the answer: If there is some kind a service which is not registered in Dependency Injection, then there will be 500 error in swagger - for any request. Any call will be faced with thrown exception before reaching the controller.
I am having some problems with jmeter. When i try to submit values to a form they don't appear there in the updated list. I am trying to check a feature of adding restaurants of a web app based on a local server right now. In the view results tree it appears successful. I put the id of the parameter by getting it from the page source and then write the value for it in the value column. Can please someone guide me through the process?
JMeter actually dose not cares about what page it has got back as response, any response with status 200 will make it successful. It is users responsibility to make sure correct response is retrieved. So when you submit a form through JMeter to add a restaurant, make sure the response for it has success confirmation of restaurant added.
Following SSujesh answer, If for example you will do a false login in drupal - you still get 200OK ...
Try and find out if there is a key that is generated per user that you need to extract, for example:
Druapl will issue a form_build_id that you will need to extract (every time you initiate a login) and then pass while you do the post request...
Same goes to aspx.
gl,
Refael
I'm using MVC4 and VS2012.
In my client code I have a jquery post that calls a controller action that performs a database update and returns a json result.
Everything works fine. However, if I put a breakpoint on the first line of my action method the program execution pauses there as expected. If I now click stop the program terminates as expected. However my database updates??? Using Fiddler I can see that the action is completing and a result is coming back from my action.
I am not double submitting the action or anything like that.
Is this the default behaviour. Is there a setting that terminates ajax request on stopping debug?
Regards
Phillip
I got few doubts on sessions in JSF and/or in general.
First up, does session gets created on load of an web app in AS/servlet container? Meaning, after I do right click- run as - run on server and the app is started and synchornised?
Or does it get created after the web app is loaded and the defined welcome page is displayed and then the client makes a request?
Second: I was looking into the issue of "Cannot create a session after the response has been committed" in jsf.
I was trying to reproduce the issue by doing this given in the following site,
http://java.net/jira/browse/JAVASERVERFACES-2215
But, I didnt get any error as mentioned above. I tried with all bean scope.
Was the session created?
This is the code.
<h:body>
<h:form id="test">
<p:growl id="msg"></p:growl>
<h:outputText value="#{myTestBean.exceedBuffer}" />
</h:form>
</h:body>
bean code is.
public String getExceedBuffer() {
int size = FacesContext.getCurrentInstance().getExternalContext().getResponseBufferSize();
char[] chars = new char[size];
Arrays.fill(chars, 'x');
return new String(chars);
}
My understanding is the following,
First when the app is loaded the servlet container or an AS creates a session and a sessionID(JSESSIONID) and puts it in server memory. So the initial page gets loaded up anyhow, meaning even if the response buffer is overflowed or not but the session wont be created. Now, when the client makes a request on this page, since the session was not created, the error occurs. But, I tried even doing this by
<p:commandButton actionListener="#{myTestBean.onSelect}" update=":test"></p:commandButton>
and in onSelect method just entered a dummy code. Even now the page displayed as usual.
Well, that was when I was completely lost. Can someone pls help me on this? Thanks in advance.
First up, does session gets created on load of an web app in AS/servlet container? Meaning, after I do right click- run as - run on server and the app is started and synchornised?
Or does it get created after the web app is loaded and the defined welcome page is displayed and then the client makes a request?
It's created on start of the HTTP session, not on webapp's startup (that's the application scope). Basically, when request.getSession() is called for the first time and the HttpSession hasn't been created yet. This all is handled by the Servlet API which JSF is using under the covers. So the following answer should help in understanding how it works: How do servlets work? Instantiation, sessions, shared variables and multithreading
Second: I was looking into the issue of "Cannot create a session after the response has been committed" in jsf.
I was trying to reproduce the issue by doing this given in the following site, http://java.net/jira/browse/JAVASERVERFACES-2215
But, I didnt get any error as mentioned above. I tried with all bean scope. Was the session created?
You will get this error when the HttpSession isn't created yet at the moment the response is committed. That you didn't get this error can only mean that the session has already been created beforehand. You need to test it on a freshly started webapp and the session shouldn't be created yet. Note that some servers by default stores sessions on shutown/restart. You'd need to disable this or to remove the JSESSIONID cookie in your browser before sending the first request on this test page. Restarting the webbrowser or using a different one should also force a fresh new session.
I have an MVC3 project using nHibernate, Rhino and Castle. I finally got all of the components in place. I think. At least it runs and invokes the IWondsorContainer CreateContainer() method....after that method, the Application_Start does not fire and I get the message:
Server Error in '/' Application.
--------------------------------------------------------------------------------
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Views/Proposal/Index.cshtml
Any ideas? I don't know what to make of this. Thanks
You seem to be requesting a view directly: /Views/Proposal/Index.cshtml. In ASP.NET MVC you do not request a view. You request a controller action. So in your browser the url should be /Proposal/Index or simply / depending on how your routes are configured.
I suspect that you had the focus on this Index.cshtml when you hit F5 in Visual Studio which has this ugly habit of following the url. You could define a start url in the properties of your web project to avoid this behavior.