|
Newbie trying to get started... -- jceddy --
Okay, I have just begun trying to use this thing, and have been trying to get the simple "GetServerTime" example to work. (By the way, if someone has a more step-by-step example of how to set up and run AjaxPro than what is available on the web page, it would be nice.) Anyway, I'm using Visual Studio .NET 2003, .NET Framework 1.1 I've created a new C# Web Application, and added a reference to AjaxPro to it. I have a WebForm1.aspx file that looks like this: ------- <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="MyDemo.WebForm1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <html> <head> <title>WebForm1</title> <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" Content="C#"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content=" http://schemas.microsoft.com/intellisense/ie5 "><script language="javascript" src="WebForm1.js"></script> </head> <body MS_POSITIONING="GridLayout" onload="getServerTime();"> <form id="Form1" method="post" runat="server"> </form> </body> </html> ------- I have a WebForm1.aspx.cs file that looks like this: ------- using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace MyDemo { /// <summary> /// Summary description for WebForm1. /// </summary> public class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { AjaxPro.Utility.RegisterTypeForAjax(typeof(MyDemo.WebForm1)); } public DateTime GetServerTime() { return DateTime.Now; } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion } } ------- I have a Web.config file that looks like this: ------- <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.web> <httpHandlers> <add verb="POST,GET" path="ajaxpro/*ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro"/> </httpHandlers> <!-- DYNAMIC DEBUG COMPILATION Set compilation debug="true" to enable ASPX debugging. Otherwise, setting this value to false will improve runtime performance of this application. Set compilation debug="true" to insert debugging symbols (.pdb information) into the compiled page. Because this creates a larger file that executes more slowly, you should set this value to true only when debugging and to false at all other times. For more information, refer to the documentation about debugging ASP.NET files. --> <compilation defaultLanguage="c#" debug="true" /> <!-- CUSTOM ERROR MESSAGES Set customErrors mode="On" or "RemoteOnly" to enable custom error messages, "Off" to disable. Add <error> tags for each of the errors you want to handle. "On" Always display custom (friendly) messages. "Off" Always display detailed ASP.NET error information. "RemoteOnly" Display custom (friendly) messages only to users not running on the local Web server. This setting is recommended for security purposes, so that you do not display application detail information to remote clients. --> <customErrors mode="RemoteOnly" /> <!-- AUTHENTICATION This section sets the authentication policies of the application. Possible modes are "Windows", "Forms", "Passport" and "None" "None" No authentication is performed. "Windows" IIS performs authentication (Basic, Digest, or Integrated Windows) according to its settings for the application. Anonymous access must be disabled in IIS. "Forms" You provide a custom form (Web page) for users to enter their credentials, and then you authenticate them in your application. A user credential token is stored in a cookie. "Passport" Authentication is performed via a centralized authentication service provided by Microsoft that offers a single logon and core profile services for member sites. --> <authentication mode="Windows" /> <!-- AUTHORIZATION This section sets the authorization policies of the application. You can allow or deny access to application resources by user or role. Wildcards: "*" mean everyone, "?" means anonymous (unauthenticated) users. --> <authorization> <allow users="*" /> <!-- Allow all users --> <!-- <allow users=" " roles=" "/> <deny users=" " roles=" "/> --> </authorization> <!-- APPLICATION-LEVEL TRACE LOGGING Application-level tracing enables trace log output for every page within an application. Set trace enabled="true" to enable application trace logging. If pageOutput="true", the trace information will be displayed at the bottom of each page. Otherwise, you can view the application trace log by browsing the "trace.axd" page from your web application root. --> <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" /> <!-- SESSION STATE SETTINGS By default ASP.NET uses cookies to identify which requests belong to a particular session. If cookies are not available, a session can be tracked by adding a session identifier to the URL. To disable cookies, set sessionState cookieless="true". --> <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="20" /> <!-- GLOBALIZATION This section sets the globalization settings of the application. --> <globalization requestEncoding="utf-8" responseEncoding="utf-8" /> </system.web> </configuration> ------- And I have a WebForm1.js file that looks like this: ------- function getServerTime() { MyDemo.WebForm1.GetServerTime(getServerTime_callback); // asynchronous call } // This method will be called after the method has been executed // and the result has been sent to the client. function getServerTime_callback(res) { alert(res.value); } ------- When I run the web page in IE (at http://localhost/MyDemo/WebForm1.aspx ) on my machine, it loads with the following JavaScript error:------- Line: 4 Char: 3 Error: 'MyDemo' is undefined Code: 0 URL: http://localhost/MyDemo/WebFrom1.aspx ------- If I View Source on the page that is generated in the browser, I see this: ------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <html> <head> <title>WebForm1</title> <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" Content="C#"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content=" http://schemas.microsoft.com/intellisense/ie5 "><script language="javascript" src="WebForm1.js"></script> </head> <body MS_POSITIONING="GridLayout" onload="getServerTime();"> <form name="Form1" method="post" action="WebForm1.aspx" id="Form1"> <input type="hidden" name="__VIEWSTATE" value="dDwtNjU0MzcyMTk1Ozs+LRnX+0ZFY9n02Hh8L2v1AYyW38w=" /> <script type="text/javascript" src="/MyDemo/ajaxpro/prototype.ashx"></script> <script type="text/javascript" src="/MyDemo/ajaxpro/core.ashx"></script> <script type="text/javascript" src="/MyDemo/ajaxpro/converter.ashx"></script> <script type="text/javascript" src="/MyDemo/ajaxpro/MyDemo.WebForm1,MyDemo.ashx"></script> </form> </body> </html> ------- The only thing that I can figure is that the files pointed to by the first three JavaScript includes aren't actually there...although I haven't seen anywhere on any of the "Quick Start" guides associated with AjaxPro that talks about setting these up, and none of the downloads I've downloaded (6.7.11.1_DLL, AjaxPro.6.2.16.1, AjaxProStarterKit-1076) seem to include those files. So...I suspect that my problem has something to do with something I missed while setting it up, but there doesn't seem to be a sufficiently detailed set-up guide so I can tell if that's the case or not. Any help? Cheers, Joe |
|
-- JosephGuadagno --
The three files get generated "on the fly" by the AjaxPro handler. If you type http://localhost/MyDemo/ajaxpro/MyDemo.WebForm1,MyDemo.ashx into your browser an you can see the JavaScript source of the files. 90% of the times the problem is due to the namespaces. On my website ( http://josephguadagno.net/ajax.aspx ) you can get a working GetServerTime sample application.Joseph Guadagno http://josephguadagno.net |
|
-- ShandySawyer --
Joseph, I am trying to do the same exact thing as jceddy and I am getting the same exact error. I'm not sure what is wrong, but even your AjaxVB example will not work for me. The other thing that is somewhat troubling for me is when I try to access the URL that everyone keeps telling people to go to: http://localhost/EmployerProfiles/ajaxpro/EmployerProfiles.TestAJAX,EmployerProfiles.ashx it comes up with "resource not found" message from the ASP.NET compiler. What exactly is this page and why do people need to access it? Heres my code: ----------------------- /web.config ----------------------- <httpHandlers> <!-- Register the ajax handler --> <add verb="POST,GET" path="ajax/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro" /> </httpHandlers> ------------------------- /default.aspx ------------------------- <%@ Page Language="vb" AutoEventWireup="false" Codebehind="default.aspx.vb" Inherits="EmployerProfiles.TestAJAX"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " http://www.w3.org/TR/xhtml1/DTD/xhmtl1strict.dtd "><HTML> <HEAD> <title>default</title> <script language="javascript" src="/javascript/TestAJAX.js"></script> </HEAD> <body> <form id="Form1" method="post" runat="server"> <button onclick="GetServerTime();" type="button">GetServerTime</button> </form> </body> </HTML> ------------------------------ /default.aspx.vb ------------------------------ Public Class TestAJAX Inherits System.Web.UI.Page Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load AjaxPro.Utility.RegisterTypeForAjax(GetType(EmployerProfiles.TestAJAX)) End Sub <AjaxPro.AjaxMethod()> _ Public Function GetServerTime() As String Return DateTime.Now.ToString() End Function End Class --------------------------------------- /javascript/TestAjax.js --------------------------------------- function GetServerTime() { EmployerProfiles.TestAJAX.GetServerTime(GetServerTime_Callback) } function GetServerTime_Callback(response) { alert(response.value); } I tried reading the other posts that handled this issue but most of them just left me confused or didn't provide a solution. If anyone could reveal some light as to what I need to do that would be great! Thanks! Shandy |
|
-- JosephGuadagno --
The page http://localhost/EmployerProfiles/ajaxpro/EmployerProfiles.TestAJAX,EmployerProfiles.ashx basically holds the JavaScript objects that will interact with the server and call the correct ASP.NET pages and methods.Did you check to see what the response.error displays within the callback, this might lead you to the problem. On 7/18/06, shandy.sawyer <shandy.sawyer> wrote: Joseph, I am trying to do the same exact thing as jceddy and I am getting the same exact error. I'm not sure what is wrong, but even your AjaxVB example will not work for me. The other thing that is somewhat troubling for me is when I try to access the URL that everyone keeps telling people to go to: http://localhost/EmployerProfiles/ajaxpro/EmployerProfiles.TestAJAX,EmployerProfiles.ashx it comes up with "resource not found" message from the ASP.NET compiler. What exactly is this page and why do people need to access it? Heres my code: ----------------------- /web.config ----------------------- <httpHandlers> <!-- Register the ajax handler --> <add verb="POST,GET" path="ajax/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro" /> </httpHandlers> ------------------------- /default.aspx ------------------------- <%@ Page Language="vb" AutoEventWireup="false" Codebehind="default.aspx.vb" Inherits="EmployerProfiles.TestAJAX"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " http://www.w3.org/TR/xhtml1/DTD/xhmtl1strict.dtd "><HTML> <HEAD> <title>default</title> <script language="javascript" src="/javascript/TestAJAX.js"></script> </HEAD> <body> <form id="Form1" method="post" runat="server"> <button onclick="GetServerTime();" type="button">GetServerTime</button> </form> </body> </HTML> ------------------------------ /default.aspx.vb ------------------------------ Public Class TestAJAX Inherits System.Web.UI.Page Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load AjaxPro.Utility.RegisterTypeForAjax(GetType(EmployerProfiles.TestAJAX)) End Sub <AjaxPro.AjaxMethod()> _ Public Function GetServerTime() As String Return DateTime.Now.ToString() End Function End Class --------------------------------------- /javascript/TestAjax.js --------------------------------------- function GetServerTime() { EmployerProfiles.TestAJAX.GetServerTime(GetServerTime_Callback) } function GetServerTime_Callback(response) { alert(response.value); } I tried reading the other posts that handled this issue but most of them just left me confused or didn't provide a solution. If anyone could reveal some light as to what I need to do that would be great! Thanks! Shandy > -- Joseph Guadagno http://josephguadagno.net |
|
-- ShandySawyer --
Are you asking for something like this? function GetServerTime_Callback(response) { alert(response.error); } Unfortunately I am getting an error like so: Line: 4 Char: 2 Error: 'Test' is undefined Code: 0 URL: http://localhost/employerprofiles/default.aspx So its not even getting into the callback function, which won't allow me to display the response.error. Were you thinking of something else? |
|
-- JosephGuadagno --
I would have to assume that the namespace you are using is EmployerProfiles... I did notice that the page name and class name are different and I dod not know if that will cause an issue. Try adding the namespace attribute to the GetServerTime method <AjaxMethod(), AjaxNameSpace("EmployerProfiles")>_ Public Function GetServerTime() As DateTime Return DateTime.Now End Function Then in the JavaScript files change the call to EmployerProfiles.GetServerTime(GetServerTime_Callback) Joseph Guadagno http://josephguadagno.net On 7/18/06, shandy.sawyer <shandy.sawyer> wrote: Are you asking for something like this? function GetServerTime_Callback(response) { alert(response.error); } Unfortunately I am getting an error like so: Line: 4 Char: 2 Error: 'Test' is undefined Code: 0 URL: http://localhost/employerprofiles/default.aspx So its not even getting into the callback function, which won't allow me to display the response.error. Were you thinking of something else? > -- Joseph Guadagno http://josephguadagno.net |
|
-- jceddy --
Joseph, When I run the VB application from the directory you gave me, I ran into the same problem. Specifically, if I hit the "GetServerTime Async" button, a "Getting time" message appears, and then the following JavaScript error is raised: ------- Line: 12 Char: 2 Error: 'AjaxVB' is undefined Code: 0 URL: http://localhost/AjaxVB/WebFrom1.aspx ------- If I hit the "GetServerTime Sync" button, I get the same JavaScript error, except on line 4 instead of line 12. I noticed some posts about Security Setting Medium or something (just a vague memory from browsing through the group yesterday)...could that have something to do with it? Thanks, Joe |
|
-- jceddy --
Also, just so I don't get the same answer again, I tried the following changes, and still have the same error: In WebForm1.aspx.vb: <AjaxPro.AjaxMethod()> _ Public Function GetServerTime() As String Return DateTime.Now.ToString() End Function becomes <AjaxPro.AjaxMethod(), AjaxPro.AjaxNameSpace("AjaxVB")> _ Public Function GetServerTime() As String Return DateTime.Now.ToString() End Function And in WebForm1.js: function GetServerTime_Async() { // Use asynchronize call document.getElementById("spanTime").innerHTML = 'Getting time'; // NOTE Syntax <namespace>.<classname>.method (params, callbackfunction) AjaxVB.WebForm1.GetServerTime(GetServerTime_Async_Callback); } becomes function GetServerTime_Async() { // Use asynchronize call document.getElementById("spanTime").innerHTML = 'Getting time'; // NOTE Syntax <namespace>.<classname>.method (params, callbackfunction) WebForm1.GetServerTime(GetServerTime_Async_Callback); } Thanks, Joe |
|
-- ShandySawyer --
Actually EmployerProfiles is the name of the project. So I did away with using that as the namespace and surrounded my class with a "TestNamespace" Namespace and tried every possible combination but I keep getting a namespace undefined error. I then added <AjaxNamespace("TestNamespace")> to the function, but that didn't do anything either. Currently it will tell me that "TestNamespace is undefined". I even tried renaming the page name and the class name as the same. I didn't do anything, but i'm pretty sure that it won't matter as long as the @ Page Directive points to the right class. I am getting beyond frustrated here.... Here are my new aspx.vb file and javascript file: ------------------------------- /TestAJAX.aspx.vb ------------------------------- Namespace TestNamespace Public Class TestAJAX Inherits System.Web.UI.Page Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Register the page for use with the AjaxPro library. This creates the 'JavaScript files on the server for the class and methods. AjaxPro.Utility.RegisterTypeForAjax(GetType(TestNamespace.TestAJAX)) End Sub <AjaxPro.AjaxMethod(), AjaxPro.AjaxNamespace("TestNamespace")> _ Public Function GetServerTime() As String Return DateTime.Now.ToString() End Function End Class End Namespace -------------------------------------- /javascript/TestAJAX.js -------------------------------------- function GetServerTime() { TestNamespace.TestAJAX.GetServerTime(GetServerTime_Callback) } function GetServerTime_Callback(response) { alert(response.value); } |
|
-- ShandySawyer --
jceddy, Apparently the new version 6.7.19.1 fixes the issue of running medium trust web applications. So I downloaded the new AjaxPro.dll (version 6.7.19.1, you can get it off the website now) and added a reference to it (after deleting the old one). Unfortunately, it didn't do anything for me, so I don't think thats the problem. However I have no idea what to do because the documentation on Ajax.NET isn't very useful, just a bunch of test cases. Shandy |
|
-- jceddy --
Shandy, Yep, I also grabbed the 6.7.19.1 version and switched to the new .dll, without it changing anything...so I don't think it's the medium trust issue. As far as I can tell, there is supposed to be some JavaScript being dynamically generated, and it's not being dynamically generated (or maybe dynamically generated in the wrong place?), but I don't know how to test it. Ah, well, will tinker around with it a bit more and see what I can figure out. Cheers, Joe |
|
-- ShandySawyer --
Joe, I'm pretty sure your on the right track. One thing that I have noticed is that in VS .NET it seems to treat your project name as a namespace as well (I'm using VS 2002, but its supposedly the same as 2003 but with some updates). Then when I look at the source code in the browser for the aspx, it uses the project name in front of the namespace like so: <script type="text/javascript" src="/ajaxpro/ .ashx"></script> I'm not sure if the namespace around your class is actually required. I have been trying out both scenarios but neither seem to work. I'm also wondering is if there needs to be permissions set in IIS to allow for the .ashx files? Shandy |
|
-- jceddy --
Shandy, The source code that is being generated by my project doesn't include the project name...although the project name and the namespace are the same, so maybe that's a difference. Basically, the whole fact that the /ajaxpro/ directory contents is dynamically generated (?) confuses me...it seems strange that you can have a JavaScript include referencing a file in a directory that you can't simply access from the web browser. For example, the following line is generated in the output of the AjaxVB project: <script type="text/javascript" src="/AjaxVB/ajaxpro/prototype.ashx"></script> But " http://localhost/AjaxVB/ajaxpro/prototype.ashx " is not a page that I can access on my web server.I have an idea that this is the root of my problems...a sneaking suspicion that I SHOULD be able to access that page in my browser, and see the JavaScript output, but I don't know where that page comes from, or when or how it is generated. Cheers, Joe |
|
-- JosephGuadagno --
Please email me the sample to jguadagno (at) gmail.com and I will look at it (or post it to this thread). Joe |
|
-- jceddy --
Joseph, It's the same thing that is posted on your site at http://josephguadagno.net/ajax.aspx The GetServerTime example with a project in it called "AjaxVB". Do you want me to just send you the code that you have there? |
|
-- ShandySawyer --
Well its the same as it was before, but here it is: ---------------------------- /TestAJAX.aspx ---------------------------- <%@ Page Language="vb" AutoEventWireup="false" Codebehind="TestAJAX.aspx.vb" Inherits="EmployerProfiles.TestNamespace.TestAJAX"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " http://www.w3.org/TR/xhtml1/DTD/xhmtl1-strict.dtd "><HTML> <HEAD> <title>default</title> <script language="javascript" src="/employerprofiles/javascript/TestAJAX.js"></script> </HEAD> <body> <form id="Form1" method="post" runat="server"> <button onclick="GetServerTime();" type="button">GetServerTime</button> </form> </body> </HTML> ------------------------------- /TestAJAX.aspx.vb ------------------------------- Namespace TestNamespace Public Class TestAJAX Inherits System.Web.UI.Page #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Register the page for use with the AjaxPro library. This creates the 'JavaScript files on the server for the class and methods. AjaxPro.Utility.RegisterTypeForAjax(GetType(EmployerProfiles.TestNamespace.TestAJAX)) End Sub <AjaxPro.AjaxMethod(), AjaxPro.AjaxNamespace("EmployerProfiles")> _ Public Function GetServerTime() As String Return DateTime.Now.ToString() End Function End Class End Namespace -------------------------------------- /javascript/TestAJAX.js -------------------------------------- function GetServerTime() { TestNamespace.TestAJAX.GetServerTime(GetServerTime_Callback) } function GetServerTime_Callback(response) { alert(response.value); } --------------------- /web.config --------------------- <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> </appSettings> <system.web> <httpHandlers> <!-- Register the ajax handler --> <add verb="POST,GET" path="ajax/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro" /> </httpHandlers> </system.web> </configuration> ----------------------- project settings ----------------------- -Using VS .NET 2002 -reference made to AjaxPro in references folder -AjaxPro.dll is version 6.7.19.1 |
|
-- JosephGuadagno --
I downloaded the code from http://josephguadagno.net/Documents/AjaxVB.zip , removed the reference to AjaxPro and replaced it with version 6.6.22.1 and it worked.So a couple of additional questions. Is this local? I assumed that the Virtual Directory has the folder (or the page would not show). JavaScript is not turned off. If you open IE and go to http://localhost/AjaxVB/ajaxpro/AjaxVB.WebForm1,AjaxVB.ashx (which should be able to be seen if you view source of the sample on my site).Do you see the following... if(typeof AjaxVB == "undefined") AjaxVB={}; AjaxVB.WebForm1_class = function() {}; Object.extend(AjaxVB.WebForm1_class.prototype, Object.extend(new AjaxPro.AjaxClass(), { GetServerTime: function() { return this.invoke("GetServerTime", {}, this.GetServerTime.getArguments().slice(0)); }, url: '/AjaxVB/ajaxpro/AjaxVB.WebForm1,AjaxVB.ashx' })); AjaxVB.WebForm1 = new AjaxVB.WebForm1_class(); If you notice, the JavaScript call would be AjaxVB.WebForm1.GetServerTime (<namespace>.<classname>.<method>). Let me know. Joseph Guadagno |
|
-- ShandySawyer --
This project is not the localhost. Its on a webserver and is set up in the EmployerProfiles subweb. So when you refer to the root "/" your really refering to "/EmployerProfiles/". Javascript is not turned off. I am not using the AjaxVB project but I am using a project that is set up exactly like it. The only different is the javascript functions are simpler (i'm using the ones provided on Michael Schwarz's website). I tried accessing that page that you refer to for my own project, but asp.net tells me that the resource cannot be found. In the source code it gives me a reference like so: <script type="text/javascript" src="/EmployerProfiles/ajaxpro/EmployerProfiles.TestNamespace.TestAJAX,EmployerProfiles.ashx"></script> As you can see its trying access the page like so: src="/EmployerProfiles/ajaxpro/<projectname>.<namespace>.<classname>,<projectname>.ashx As a result I have tried to make a JavaScript call like so: EmployerProfiles.TestNamespace.TestAJAX.GetServerTime() But this does not work as well. From what I can tell, it just considers the project name another namespace when I hover over the name in VS. I think I will try checking permissions for the .ashx to make sure it is not being blocked by the server. Let me know if you think of anything else. |
|
-- jceddy --
Joseph, Maybe there's something bogus about the way my directory structure is set up? My root directory is c:\Inetpub\wwwroot Within that directory, there is a "AjaxVB" directory, which contains the following files: AjaxVB.sln AjaxVB.suo AjaxVB.vbproj AjaxVB.vbproj.webinfo AssemblyInfo.vb Global.asax Global.asax.resx Global.asax.vb Styles.css Web.config WebForm1.aspx WebForm1.aspx.resx WebForm1.aspx.vb WebForm1.js WebForm2.aspx WebForm2.aspx.resx WebForm2.aspx.vb WebForm2.js and a subdirectory called "bin" that contains the following files: AjaxPro.dll AjaxVB.dll AjaxVB.pdb The AjaxPro.dll is version 6.7.19.1 Everything else is the same as the original download except that I set WebForm1.aspx as the Start Page for the Web Application. The IIS Virtual Directory settings for the AjaxVB directory has the following options set: The content for this resource should come from: The designated directory. Global Read permissions are allowed Log visits is enabled Index this resource is enabled Application name: AjaxVB Starting point: <Default Web Site>\AjaxVB Execute permissions: Scripts only Application pool: DefaultAppPool The application is running on my local machine, accessed at the following URL: http://localhost/AjaxVB/WebForm1.aspx If I open IE and go to http://localhost/AjaxVB/ajaxpro/AjaxVB.WebForm1,AjaxVB.ashx ,I get a "The Page Could Not Be Found" error There isn't an "ajaxpro" directory anywhere that I could find...should there be one? Are we supposed to create it as part of the set-up for our applications? Cheers, Joe |
|
-- JosephGuadagno --
Everything looks good. Inside the web.config file there should be a section for httpHandlers which registers the ashx file extension. Once ASP.NET sees a ashx file extension it routes the call to the AjaxPro library. What does is in the page when you choose View Source within IE? On 7/19/06, jceddy <jceddy> wrote: Joseph, Maybe there's something bogus about the way my directory structure is set up? My root directory is c:\Inetpub\wwwroot Within that directory, there is a "AjaxVB" directory, which contains the following files: AjaxVB.sln AjaxVB.suo AjaxVB.vbproj AjaxVB.vbproj.webinfo AssemblyInfo.vb Global.asax Global.asax.resx Global.asax.vb Styles.css Web.config WebForm1.aspx WebForm1.aspx.resx WebForm1.aspx.vb WebForm1.js WebForm2.aspx WebForm2.aspx.resx WebForm2.aspx.vb WebForm2.js and a subdirectory called "bin" that contains the following files: AjaxPro.dll AjaxVB.dll AjaxVB.pdb The AjaxPro.dll is version 6.7.19.1 Everything else is the same as the original download except that I set WebForm1.aspx as the Start Page for the Web Application. The IIS Virtual Directory settings for the AjaxVB directory has the following options set: The content for this resource should come from: The designated directory. Global Read permissions are allowed Log visits is enabled Index this resource is enabled Application name: AjaxVB Starting point: <Default Web Site>\AjaxVB Execute permissions: Scripts only Application pool: DefaultAppPool The application is running on my local machine, accessed at the following URL: http://localhost/AjaxVB/WebForm1.aspx If I open IE and go to http://localhost/AjaxVB/ajaxpro/AjaxVB.WebForm1,AjaxVB.ashx ,I get a "The Page Could Not Be Found" error There isn't an "ajaxpro" directory anywhere that I could find...should there be one? Are we supposed to create it as part of the set-up for our applications? Cheers, Joe > -- Joseph Guadagno http://josephguadagno.net |
|
-- JosephGuadagno --
Do they have any machine level .NET permissions configured? Namely with the use of Reflection? On 7/19/06, shandy.sawyer <shandy.sawyer> wrote: Checked with the server admin on the server settings and it is not being blocked by server. > -- Joseph Guadagno http://josephguadagno.net |
|
-- ShandySawyer --
No permissions are configured for .NET either |
|
-- ShandySawyer --
Checked with the server admin on the server settings and it is not being blocked by server. |
|
-- jceddy --
Joseph, The following lines are in the Web.config file: <httpHandlers> <add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro"/> </httpHandlers> Which is from the website referenced above. When I view source in IE, for the URL http://localhost/AjaxVB/WebForm1.aspx , the content is:------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>WebForm1</title> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content=" http://schemas.microsoft.com/intellisense/ie5 "><script src="WebForm1.js" language="javascript" type="text/javascript"></script> </HEAD> <BODY> <form name="Form1" method="post" action="WebForm1.aspx" id="Form1"> <input type="hidden" name="__VIEWSTATE" value="dDwtNjU0MzcyMTk1Ozs+yCkyU5hagp5x43S4j4N5TeW9eUM=" /> <script type="text/javascript" src="/AjaxVB/ajaxpro/prototype.ashx"></script> <script type="text/javascript" src="/AjaxVB/ajaxpro/core.ashx"></script> <script type="text/javascript" src="/AjaxVB/ajaxpro/converter.ashx"></script> <script type="text/javascript" src="/AjaxVB/ajaxpro/AjaxVB.WebForm1,AjaxVB.ashx"></script> <button onclick="GetServerTime_Async();" type="button">GetServerTime Async</button> <button onclick="GetServerTime_Sync();" type="button">GetServerTime Sync </button> <br> <span id="spanTime"></span> </form> </BODY> </HTML> ------- And, as before, if I attempt to load the URL http://localhost/AjaxVB/ajaxpro/prototype.ashx , I get a page cannot be found error.Is the "ajaxpro" directory a physical directory that should be there, or is it some kind of virtually directory that is magically there through virtue of having AjaxPro.dll in the bin directory of the project? (Don't know if this is a stupid question or not, because I haven't used ASP much.) Thanks, Joe |
|
-- JosephGuadagno --
When you register the httpHandler in the Web.Config all of the ashx files will be redirected to the AjaxPro library. I can not think of anything else. Micheal can you help? |
|
-- jceddy --
Does the AjaxPro library need to be installed somewhere specific? Somewhere else besides the directory that this script is running in? Or should it be enough that I've added a reference to it in the project and it's being copied to the project's local bin directory? |
|
-- jceddy --
Does it matter that for the Default Web Server (the server this application is running on) IIS has an extension mapping for the extension .ASHX for verbs "GET, HEAD, POST, DEBUG" to .NET 1.1's aspnet_isapi.dll? Maybe there is some setting that keeps AjaxVB's Web.config file from overriding this setting? -- Joe |
|
-- JosephGuadagno --
I do not think it matters that the IIS installation has the ashx registered to aspnet_isapi.dll. I believe that IIS can have multiple handlers. As far as the DLL is concerned, it does need to be referenced. When you reference the DLL, Visual Studio will place it in the \bin directory. If you where able to successful "build" the project in Visual Studio the DLL is referenced. Joseph Guadagno http://josephguadagno.net |
|
-- ShandySawyer --
Joe, I brought my laptop in today so I'm going to see if I can get the AjaxVB example working on it. I'll keep you updated. Shandy |
|
-- ShandySawyer --
Joe, Well I was able to get both the AjaxVB project to work on my laptop as well as my own project with just the GetServerTime method. I didn't even have to use the <AjaxPro.Namespace()> method for the GetServerTime function. This was under localhost using VS 2003 and IIS 5.1 on XP. So I'm at a loss as to what could be wrong on the server I'm trying to get AjaxPro to work. I'm going to try using VS 2003 on a different machine and see if I can get something working because right now I'm using VS 2002 on this machine. I'll keep you updated. Shandy |
|
-- jceddy --
Thanks, Shandy. It seems fairly obvious to me that one of two things are happening: 1) The <httpHandlers> specification in Web.config is being ignored for some reason. 2) Something in the system is blocking ASP.NET from routing the GET for the "JavaScript" .ashx files to the appropriate method in the AjaxPro .dll Either way the end result is that the server thinks the client is requesting files that aren't there. Knowing my luck, the problem is probably due to some obscure IIS, Security, ASP, or VS setting that everyone in the world has set differently than me, so no-one's ever going to be able to replicate it. ;o) Do you think there might be some server logs that would have some helpful information on tracking down what exactly is going wrong? Cheers, Joe |
|
-- ShandySawyer --
Ok so after I was able to get it working on my laptop with VS 2003, I went and tried it on a machine that had VS 2003, but I didn't have any kind of luck. Still getting the error message "<Namespace> undefined". I was able to figure out how VS is putting a namespace that is same as the project name. If you right-click the project in the solution explorer and go to the properties, in the window that pops up there is a field called "Root namespace." So you can pretty much name it whatever you want, or if you leave it blank then you can refer to the class directly. But I still have no idea what is wrong and I'm about ready to call it quits. |
|
-- jceddy --
Shandy, On the new machine you're trying to run it on, can you access the "JavaScript" .ashx scripts from the browser and see the output? I'm just curious if your problem is the same as mine or not. Cheers, Joe |
|
-- jceddy --
I'm going to give it another day before I give up. ;o) |
|
-- ShandySawyer --
Yeah I checked the .ashx script and its there, I think it gets created on the fly which is why we can't see it anywhere on there server. Hence the strange syntax "AjaxVB.Webform1,AjaxVB.ashx". I'm really starting to think its some kind of filter or permissions setting that maybe isn't allow the .ashx to be created. When I try to access the .ashx script on my machine, ASP.NET send me an error message saying that the resource cannot be found. Is that what your getting or are you getting an all out 404 error message? |
|
-- jceddy --
I'm getting 404 messages...here is the relative snippet from my IIS log: 2006-07-20 15:40:48 127.0.0.1 GET /AjaxVB/WebForm1.aspx - 80 - 127.0.0.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+SV1;+.NET+CLR+1.1.4322;+InfoPath.1) 200 0 0 2006-07-20 15:40:48 127.0.0.1 GET /AjaxVB/WebForm1.js - 80 - 127.0.0.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+SV1;+.NET+CLR+1.1.4322;+InfoPath.1) 304 0 0 2006-07-20 15:40:48 127.0.0.1 GET /AjaxVB/ajaxpro/prototype.ashx - 80 - 127.0.0.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+SV1;+.NET+CLR+1.1.4322;+InfoPath.1) 404 0 3 2006-07-20 15:40:48 127.0.0.1 GET /AjaxVB/ajaxpro/core.ashx - 80 - 127.0.0.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+SV1;+.NET+CLR+1.1.4322;+InfoPath.1) 404 0 3 2006-07-20 15:40:48 127.0.0.1 GET /AjaxVB/ajaxpro/converter.ashx - 80 - 127.0.0.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+SV1;+.NET+CLR+1.1.4322;+InfoPath.1) 404 0 3 2006-07-20 15:40:48 127.0.0.1 GET /AjaxVB/ajaxpro/AjaxVB.WebForm1,AjaxVB.ashx - 80 - 127.0.0.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+SV1;+.NET+CLR+1.1.4322;+InfoPath.1) 404 0 3 2006-07-20 15:42:02 127.0.0.1 GET /AjaxVB/ajaxpro/prototype.ashx - 80 - 127.0.0.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+SV1;+.NET+CLR+1.1.4322;+InfoPath.1) 404 0 3 2006-07-20 15:42:34 127.0.0.1 GET /AjaxVB/ajaxpro/ - 80 - 127.0.0.1 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+SV1;+.NET+CLR+1.1.4322;+InfoPath.1) 404 0 2 The first six lines are from loading the main page in a browser, the last two lines are from me attempting to load just "prototype.ashx" in a browser. I'm guessing that you're right about some filter or permissions setting that might not be allowing the .ashx file to be created on the fly, but am at a loss on how to track down what it is. Is there an ASP log separate from the IIS log that you know of? -- Joe |
|
-- ShandySawyer --
No I don't know of any ASP log, but I haven't dealt much with log files so I'm not the person to ask. I tried searching it on google but didn't come up with much expect this http://www.aspfaq.com/show.asp?id=2335 /. I don't have rights to install programs on this machine so you might give it a try and see what you come up with.Shandy |
|
-- ShandySawyer --
I was also searching my laptop for .net permissions and I was able to find something that I was hoping maybe you could look at so that we could compare. If you go to Admininstrative Tools -> Microsoft .NET Framework 1.1 Configuration Then in the navigation expand Runtime Security Policy -> expand User -> expand Permission Sets -> Internet Then in the right hand main window right click on Security and go to View Permission In my list just the first item has a "Yes" value in the granted column. The rest have "No". You can also check the same for the Machine and Enterprise sections as well, they are the same as the user for me as well. |
|
-- JosephGuadagno --
I have the same permissions. On 7/20/06, shandy.sawyer <shandy.sawyer> wrote: I was also searching my laptop for .net permissions and I was able to find something that I was hoping maybe you could look at so that we could compare. If you go to Admininstrative Tools -> Microsoft .NET Framework 1.1 Configuration Then in the navigation expand Runtime Security Policy -> expand User -> expand Permission Sets -> Internet Then in the right hand main window right click on Security and go to View Permission In my list just the first item has a "Yes" value in the granted column. The rest have "No". You can also check the same for the Machine and Enterprise sections as well, they are the same as the user for me as well. > -- Joseph Guadagno http://josephguadagno.net |
|
-- ShandySawyer --
Ok so heres the deal, I talked with our server admin who so gracefully pointed out to me that its not finding those pages because its looking for the dll on the server. However after our conversation I failed to mention that the dll gets placed in the bin folder that should be located on the server. But she brought up a good point on why it would be working on a localhost application but then wouldn't work when trying to run it on a server. So my question is, does this dll need to be placed on the server, or is giving a reference to the dll good enough? |
|
-- JosephGuadagno --
Yes the dll needs to \bin directory. Anytime you reference a DLL in a ASP.NET application it needs to be placed in the \bin subdirectory of the application or available in the Global Assembly Cache (GAC). Sorry I just assumed you copied all of the files. Joseph Guadagno On 7/20/06, shandy.sawyer <shandy.sawyer> wrote: Ok so heres the deal, I talked with our server admin who so gracefully pointed out to me that its not finding those pages because its looking for the dll on the server. However after our conversation I failed to mention that the dll gets placed in the bin folder that should be located on the server. But she brought up a good point on why it would be working on a localhost application but then wouldn't work when trying to run it on a server. So my question is, does this dll need to be placed on the server, or is giving a reference to the dll good enough? > -- Joseph Guadagno http://josephguadagno.net |
|
-- jceddy --
Those permissions are the same for me...AND the .dll is in the bin folder in the virtual directory. |
|
-- jceddy --
Nevermind, that's not it, either...it seems like the commands in the Web.config file for the ajaxpro subdirectory only are not working. |
|
-- jceddy --
It's wierd...it's like it's checking that the files exist before going to the handler, so it's sending back the 404 response before it even goes to AjaxPro. Hmm.... |
|
-- jceddy --
Well, I've pretty much verified now that the root of my problem is that the Web.config file for the project is not actually being loaded. Any idea why that might be? |
|
-- ShandySawyer --
Where do you find that setting? |
|
-- ShandySawyer --
Ya see when you right click on the references folder and then select add reference and then add the AjaxPro dll under the .NET tab, it then copies the dll into the bin folder. Or do you manually have to copy the dll to the bin folder? |
|
-- jceddy --
Load IIS Manager Bring up the "Properties" page for the appropriate web site (I expand the machine, then "Web Sites" then right-click -> Properties on the Web Site my application is hosted on) Select the "Home Directory" tab Click the "Configuration..." button near the bottom-right corner Double-click the application extension (in this case .ASHX) In the botton-left corner there should be a checkbox labeled "Verify that file exists" In my configuration it was checked, which I think is actually the default when adding an extension mapping by hand...which I had to do earlier this week to get ASP.NET to run at all. Apparently, if it's checked, it will serve up a 404 if the file doesn't exist, before even going to an httpHandler that you might have defined, so the whole "on-the-fly file generation" thing gets broken. -- Joe |
|
-- ShandySawyer --
Nevermind I found it. For those who are wondering go to: Administrative Tools -> Internet Information Systems -> expand local computer -> expand websites -> right click the virtual server your working on (usually just "Default Web Site") -> Properties -> Home Directory Tab -> Configuration Button -> Select the .ashx extension -> Edit Button -> Check That File Exists Tab should be unchecked. Joseph, you should see about adding this into your documentation :) Shandy |
|
-- jceddy --
Finally figured it out. It was simply that the IIS mapping for the .ashx extension had the "verify file exists" option selected...hopefully this is helpful for anyone else who decides to use AjaxPro as their first foray into ASP.NET programming. ;o) Have a good day, Joe |
|
-- ShandySawyer --
When trying to use AjaxPro on a server, is it good enough to make a reference to it in the project or do you manually have to copy it somewhere on the server? I figured just adding a reference to it was good enough because then the dll appears in the bin folder, which would then exist on the server since the projects are on the server. What is the Global Assembly Cache (GAC) and where is it? |
|
-- JosephGuadagno --
Referencing the DLL in your project and copying it to the bin directory of your curretn web application should be enough. The Global Assembly Cache, is the old equivalent to the Windows\System32 directory. Unfortunately, only strongly named and signed DLLs can go in the GAC. I do not believe the current version of AjaxPro is signed. Joseph Guadagno On 7/22/06, shandy.sawyer <shandy.sawyer> wrote: When trying to use AjaxPro on a server, is it good enough to make a reference to it in the project or do you manually have to copy it somewhere on the server? I figured just adding a reference to it was good enough because then the dll appears in the bin folder, which would then exist on the server since the projects are on the server. What is the Global Assembly Cache (GAC) and where is it? > -- Joseph Guadagno http://josephguadagno.net |