I ran an ASP.NET page that i have under development on my local IIS. It uses some dragPanelExtenders as well as some other AJAX Control Toolkit AJAX client side stuff, and in order to show the page to somebody, I wanted to put it up as a plain HTML file, hosted on a live web server (running APACHE). (This is the only public web server I have access to, and I want them to be able to drag some panels and experience the page as it would be when "live")
So, I viewed the page running on my local IIS, then saved the source as a HTML file.
Then copied this HTML file to the web server ( as well as necessary CSS, JS and image files).
When I view this HTML file through the web server, I get this error :
ASP.NET Ajax client-side framework failed to load.
By debugging, I see that the following lines were in my saved HTML :
<script src="/Insata10/WebResource.axd?d=VAXZudqFsChpNfB" type="text/javascript">
<script src="/Insata10/ScriptResource.axd?d=Dwbyv-OIp-kJQdqf_UMh7wUzi2" type="text/javascript">
<script type="text/javascript">
if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');
So, at runtime, the referenced resources "ScriptResource.axd" and "WebResource.axd" were not found.
Is there any way to get whatever is needed from those AXD's to my HTML file, without actually executing anything on IIS?
Not easily. The Ajax Control Toolkit relies on server-side .NET Code, which runs in the context of IIS.
You can us a different web server, such as the Cassini web server that comes with Visual Studio (or write your own), but I expect that you're looking for a simpler solution, and none exist for what you're asking.
The bottom line is, the server-side code needs to run, and for that you need a server. You can't just open the file and have it work.
The best you could do would be to find similar javascript to get the desired funcitonality.
edit
I'm always forgetting about Mono, so if your Apache server is set up and configured correctly, you CAN run .NET code from an Apache server. http://www.mono-project.com/ASP.NET
Still not simple, though, so my answer of "not easily" does not change.
Related
I'm creating an asp.net web application.
In the web application I have a web service.
I added [System.Web.Script.Services.ScriptService]
To the web service file and added a script manager to the aspx page.
When I call the web service in javascript I get an error "Microsoft JScript runtime error: 'getText' is undefined"
This same code works in another project, but it's a website project and not a web application. Maybe there is a difference between the two in this respect?
Thank you!
-Elad
What are you trying to do with getText ? Is this a valid ASP.NET AJAX command?
Assuming it is...
Not much info to go on here, but make sure you have added a reference to the .asmx file of your service on the <ScriptManager>control in your page.
You can do this in markup, or in code like this (usually during the Page Load event):
sm.Services.Add(New ServiceReference("~/YourWebService.asmx"))
Where sm is the id of your ScriptManager.
Also, if the JavaScript file you're using to call your web service is external, load it by registering it with the ScriptManager like this rather than adding a reference to it in your markup:
sm.Scripts.Add(New ScriptReference("YourJavaScriptFile.js"))
This ensures it won't run until the ScriptManager is ready.
Also, add this line to the very end of your JavaScript file:
if (typeof (Sys) !== 'undefined') {Sys.Application.notifyScriptLoaded(); }
This notifys the ScriptManager that your JavaScript file has loaded.
I switched from a web application project to a web site project and everything started working. I don't really know why this is, but it just worked.
I have a need to integrate a third-party Java applet into a custom web part I wrote for SharePoint 2007. The web part simply loads a user control I created that contains the bulk of the functionality, and that's where the applet will go. I added it to my user control project and it works fine outside of my SharePoint environment.
I installed the updated web part onto my MOSS 2007 development site and the part's page loads fine. The applet is triggered by clicking a link button on the page, which runs some client-side JavaScript to start it. The problem is nothing seems to happen when I click the link. No error messages appear, and the stuff the applet is supposed to do never occurs (it's for doing file transfers via FTP). I have the .jar file as an embedded resource in my user control DLL, which is deployed to the bin folder, and SharePoint fully trusts this DLL.
I used Firebug to step through the initialization code and I saw an HTTP GET that failed with a message about not being authorized, but it didn't give any details and I'm not positive it was related to the applet.
Is there anything special I need to do to make the applet work? Or am I going about this the wrong way?
EDIT: The problem turned out to be the .jar file for the applet couldn't be found. SharePoint is clearly doing something different here, and I need to find out what. Can Java applets be used within a SharePoint site? This question suggests they can, but in that case a Page Viewer web part was used, which isn't going to really work for me.
An applet in HTML is handled by applet/object tag. Your webpart should just render the OBJECT/applet tag and its attributes relevant to the applet (code, height, width) or you can let the JavaScript do it all and your webpart can provide the marker div where the applet needs to be rendered. That's about it and Sharepoint does not have to have any more knowledge about the applet since it is all taken care of the browser. The archive parameter points to the jar that can be located on your server than should be browsable. Instead of bundling it as a resource in the DLL , host it on the server just outside of the Sharepoint website. You might have to create a virtual directory in a different website for the same. This simplifies the deployment model.
It is possible the applet make a HTTP call back to the SharePoint site and it does not pass any credentials
I'm working on an ASP.net web application. I'm getting errors on some of my pages where I get runtime JavaScript errors.
I've narrowed the problem down to a single ASP Menu control on the master page. I created a blank page with just the ASP Menu control. The ASP Menu control is bound to Web.sitemap. The page intermittently gives runtime errors.
However, if I refresh the page, the error may or may not appear on any given page load. Sometimes, it works; sometimes, the browser throws runtime errors when loading the page or when I mouse over the ASP Menu control.
When I catch the error in Visual Studio, the message is "microsoft jscript runtime error 'sys' is undefined". When I Google for this message, I find that it is usually associated with AJAX. However, the ONLY thing on the page is a single ASP control.
There is absolutely no Javascript on the page except for what gets generated by the .net framework.
What could be causing this problem?
UPDATE I've found out that my environment actually has load balancing with a web farm of three servers servicing the URL. When I access the application on any one of the servers individually by IP address, everything works fine.
To clarify, I understand that when a user hits the public-facing URL, it resolves to x.x.x.1. x.x.x.1 is the address for a switch which routes the request to either x.x.x.2, x.x.x.3, or x.x.x.4.
When I use the public-facing URL, I find that some of the axd file requests are intermittently rerouted to Error.aspx! WTF!?!?!?!?!?
I'm told that this is the result of a security feature that is meant to protect me from cross-site scripting and other assorted bad stuff. What can I do?
Update After taking out some error page auto-redirects, I get a more meaningful error message: ASP.NET Ajax client-side framework failed to load.
Make sure all the servers have the same asp.net version. Something that could affect it, is partially applying the recent Microsoft patch for the padding oracle vulnerability (to some servers, instead of All)
Make sure all the servers use the same machine key. When doing so either use protected sections or configure it at the machine level web.config / learn from the recent vulnerability to protect sensitive information in the web.config.
In a javascript file I'm calling an ASP.NET Ajax PageMethod (ASP.NET 3.5), correctly defined in the page class a static method using the WebMethod attribute. This works on my development machine, but on the production server the PageMethod object is undefined when my javascript function is called (clicking a button).
Some debugging info:
Error on Firefox and Internet Explorer
According to Firebug's network tab all external resources are correctly loaded
I'm using jQuery on the same page
The application is deployed using a Web Deployment project
Any idea what's causing the problem?
I found the solution to the problem after having written the question. I'm doing a dirty trick in order to avoid copying the aspx placeholder files (Web Deployment Project) to the server: in IIS I've unchecked the .aspx ISAPI extension option "Verify that file exists".
That seems to be a problem for ASP.NET Ajax. So I created an empty aspx placeholder file and ... now it's working on the production server too. I'll put a warning sign on the question/answer I linked above.
I am using VS 2008 with a very simple UpdatePanel scenario.
But i cannot get UpdatePanel to work and cant seem to find out why
I have in fact reverted to a very simple example to validate it is not my code:
http://ajax.net-tutorials.com/controls/updatepanel-control/
In this example I click on either button and both text links update.
I dont get any errors, the page just behaves like a normal ASPX page.
What things do i need to check. I've been googling this for an hour and not found what I need.
Edit: Works in Visual Studio web server but not in IIS
If it's working locally, but not when deployed to a remote server, that usually indicates that you're using ASP.NET 2.0 and the ASP.NET AJAX extensions aren't installed on the remote server.
If it's a server you have administrative control over, you can download the installer here: http://www.microsoft.com/downloads/details.aspx?FamilyID=ca9d90fa-e8c9-42e3-aa19-08e2c027f5d6&displaylang=en
If it's a web host, tell them to get their act together.
Another option would be to check your web.config. You could for example create an new Ajax enabled ASP.NET website from Visual Studio. This will generate a correct web.config. Copy over all non-ajax sections from your existing web.config and you're set. This worked for me.
-Edoode