ASP .NET MVC2 problem in calling jquery.get() - asp.net-mvc-2

I am working on a ASP .NET MVC2 project where i have to load data using $.get() but it doesn't works. Although if i call same method with $.post() even giving [AcceptVerbs(HttpVerbs.Post)] above of my controller method or not it works. So i just want to ask Does Microsft has put a restriction inn calling $.get() with ASP .NET MVC2. If yes then whats the reason behind it security or anything else.

What do you mean it doesn't work? What http status code do you get? Is there an error message? Try using firebug and open the net tab to watch the result to see any errors and to also make sure it is calling the url you are expecting. Also, have you tried using jQuery $.ajax() instead of $.get()?

Are you using .Net Framework 3.5 ?
Maybe you should consider creating an Ajax enabled WCF service,
the asp postback and autopostback model can be the reason why
it doesn't work nicely .
Firebug / fiddler is your friend

Related

API Controller Routing in .NET 6 Doesn't Work Any More

I'm trying to create a standard WebAPI project in .NET 6. I notice that the standard ApiController route doesn't have the leading api route that I like to have. When I add it, the controller breaks. It doesn't give me a 404 (not found), it just gives me that index page that says that I have to enable javascript. I'm really at a loss at what I have to do to make my app work where I can put api at the start of my routes:
[Route("api/[controller]")]
I've tried adding it to the default controller route map in different combinations. I've tried adding the UseEndpoints method in the Program class. I'm just not sure what to differently in 6.
For those who want to "see my code", I'm just using the standard WebAPI project w/ React (NO Redux!).
Check the new setupProxy.js file image description inside the ClientApp folder, you need to configure the backend routes in the proxy config, I had a similar issue with the ASP.NET Core 6.0 with Angular project template, you can find more information here link 1 link 2

Calling webapi method gives 404

I don't understand this.
I have a webapi project setup locally on my own server, that works. I can go to http://mydomain.com/Api/Method and get my expected result no problem, works across 3g and everything too.
Then I have a website hosted somewhere else, in which tried to use this webapi method and this works fine when I test it locally, but as soon as I publish to the web and try it from there it fails with a 404 error?
I've tried both post and get methods and made sure the api method accepted both verbs.
I've tried calling the method both with javascript ajax and from within an MVC controller using a WebRequest.
I just don't understand why it works fine from any webbrowser, but I can't get it to work even with a programmatic WebRequest, shouldn't it be the same?
Nevermind.
Apparently, it was as simple as just setting an accept header with a value of "text/html" (in my case).
I spent way too much time figuring that out. Thanks #I4V for leading me in the right direction.

Issue with adding sudzc.xcode framework to my application

I am using web service in my IOS application. Its all the WSDL calls. So i used Sudzc.com to generate all the service call Soap requests. Here my problem is how to add the generated sudzc.xcode framework to my application. Someone told me like we can add generated .xcode framework to our application. Can any one please suggest me.
Very simple, please follow the movy that is on the sudzc page. It helped me too.
Here a link to the movy:
http://sudzc.com/Tutorial/ObjC.mov
For automatic reference counting, select it from the dropdown.

Deploying MVC2 application to IIS7.5 - Ninject asked to provide controllers for content files

I have an application that started life as an MVC (1.0) app in Visual Studio 2008 Sp1 with a bunch of Silverlight 3 projects as part of the site. Nothing fancy at all. Using Ninject for dependency injection (first version 2 beta, now the released version 2 with the MVC extensions).
With the release of .Net 4.0, VS2010, MVC2 etc., we decided to move the application to the newest platform. The conversion wizard in VS2010 apparently took care of everything, with one exception - it didn't change references to mvc1 to now point to mvc2, so I had to do that manually. Of course, this makes me think about other MVC2 things that could be missing from my app, that would be there if I did File -> New Project... But that is not the focus of this question.
When I deploy this application to the IIS 7.5 server (running on Win2008 R2 x64), the application as such works. However, images, scripts and other static content doesn't seem to exist. Of course they are there on disk on the server, but they don't show up in the client web browser.
I am fairly new to IIS, so the only trick I knew is to try to open the web page in a browser on the server, as that could give me more information. And here, finally, we meet our enemy. If I try to go directly to the URL of one of the images (http://server/Content/someimage.jpg for instance), I get the following error in the browser:
The IControllerFactory 'Ninject.Web.Mvc.NinjectControllerFactory' did not return a controller for a controller named 'Content'.
Aha. The web server tries to feed this request to MVC, who with its' default routing setup assumes Content to be a controller, and fails.
How can I get it to treat Content/ and Scripts/ (among others) as non-controllers and just pass through the static content? This of course works with Cassini on my developer machine, but as soon as I deploy, this problem hits.
I am using the last version of Ninject MVC 2 where the IoC tool should pass missing controllers to the base controller factory, but this has apparently not helped. I have also tried to add ignore routes for Content etc., but this apparently has no effect either. I am not even sure I am addressing the problem on the right level.
Does anyone know where to look to get this app going? I have full control of the web server so I can more or less do whatever I want to it, as long as it starts working.
Thanks!
I had a similar problem with StructureMap and favorite.ico what I ended up doing was to add a route to ignore that path.
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("favicon.ico");
Keep in mind that I have absolutely no idea really but another thing that changed is the need for Default.aspx, also if you have any custom pages those would need to mapped. That's the only two problems I had with routing.
routes.RouteExistingFiles = false;
EDIT: I meant that the RouteExistingFiles should be false otherwise I get that exception in MVC2 :)
Turns out this was caused by some account settings - I was unaware of the IIS AppPool\sitename account automatically being created by IIS in Win2008 R2 server. After trying "everything", I came across this information, gave the proper rights, and stuff magically started working.
Pretty hard thing to debug, especially for someone (me) with very limited IIS experience.

Asp.Net and External DLL

i'm writing a web application that works with an external dll (activex),
the dll was written by skype developers,
the problem is that,
in a case of any event (status changing, attachment, etc..) in the client side, a delegate needs to be call on the server side.
so when i'm changing a status in the skype program, it seem that a postback really happen but there is no affect on the client side.
for example , i'm trying to change a label content by his new value from the server side (using label that runat server) but nothing change.
i succedded to make a java script interval
so when it recognize any changes
it replace the content of the label.
i preffer not to use it because the dll already support that events.
thanks in advance.
It seems that your problem is simulating a post-back to make the label change its contents. If so, this link might be helpful:
Using doPostBack Function in asp.net