 |
|
 |
Hello, Alberto. "Homer" here again.
I have a couple of questions about entering values into the POST Params field (and please, I'm a sysadmin, not a developer/programmer):
1. The UserName (txtUserName), Password (txtPassword), and SignIn button parameters for our demo website are not the same as the default example given in the Untitled configuration file, so I assume that I need to change them to match what's given in the login page's source code. Only I'm not sure what to change them to. For example, the source code lists a label for="PC706_txtUsername", an input name="PC706$txtUsername", and an id="PC706_txtUsername". The password parameters are essentially the same. The submit button is equally problematic for me: input type="submit", name="PC706$btnLogin", value="Login", and id="PC706_btnLogin". What do I need to enter?
2. Your article says "don't forget to include the __VIEWSTATE parameter with a valid value in the POST params textbox" How do I do that?
Thanks again for your help. Even without making the authentication request, your precompiler makes our demo website extremely responsive on first request. In case you were wondering why I might be using this instead of the .NET 2.0 aspnet_compiler tool, it's because the Microsoft tool refuses to work if it finds a single error (and I don't have control or influence over the code). And there isn't any option for passing login parameters, either.
Have a safe and happy New Year!
|
|
|
|
 |
|
 |
Hi. Sorry for late reply, due to (finally!) some vacancies.
About your question #1:
If I'm not wrong, form POST parameters should use "name"s and not "id"s. So, you should try with:
PC706$txtUsername=yourName&PC706$txtPassword=yourPassword&PC706$btnLogin=Login
before trying with:
PC706_txtUsername=yourName&PC706_txtUsername=yourPassword&PC706_btnLogin=Login
About your question #2:
To retrieve a valid value for the VIEWSTATE param, you could:
a. navigate with your browser your login page
b. before logging in, inspect the HTML source
c. if you see inside your HTML form an INPUT hidden tag named "__VIEWSTATE", copy its "value" and supply it to the compiler tool concatenating it with other parameters:
...&PC706$btnLogin=Login&__VIEWSTATE=dDwtMzIyNjUxMzt0P...
I see you already inspected your login page HTML source: if you didn't see VIEWSTATE, maybe your login form doesn't include any VIEWSTATE.
---
In general:
if you still have problems in providing the right POST parameters, you could "sniff" them while navigating and logging in interactively on your login page (to "sniff", you could use the "Live HTTP Headers" add-on for Mozilla Firefox, for example).
Let me know if everything is okay.
Cheers, AV
|
|
|
|
 |
|
 |
That was perfect, Alberto. Many thanks. I was worried a little bit about the VIEWSTATE value because the hash value is over 3000 characters long, but your utility handled it without a problem.
|
|
|
|
 |
|
 |
I actually have more than one question, but this is the scenario: I have a VMware virtual machine that our company's sales people use to demonstrate our web-enabled software. We've tried just suspending the VMs to save the website state in between demos, but that seems to break down the VM files quickly and unexpectedly leading to some embarrassing moments. I stumbled across this wonderful utility, and demos now run much smoother and with more confidence.
I'm normally a system administrator, not a developer, so I'm wondering:
1) Is it possible to run the utility, with the appropriately identified configuration file, from a logon script or batch file? (The less a sales person has to do, the better - and we'll both be happier)
And,
2) Is it possible for the pre-compiler to make more than one Web Form Authentication request?
|
|
|
|
 |
|
 |
Hi "daleallenc".
About your question number 1:
The simplest solution is to make the tool capable of handling some command-line argument in order to understand which config file has to be loaded and if the execution has to fire immediately the precompile operation. Supposing you want to support these following execution variations:
> ASPdotNETprecompiler.exe -autorun
will automatically start the precompile operation using the default config file ("Untitled.cfg")
> ASPdotNETprecompiler.exe MyConfig.cfg
will automatically load the specified config file ("MyConfig.cfg")
> ASPdotNETprecompiler.exe -autorun MyConfig.cfg
will automatically load the specified config file ("MyConfig.cfg") and start the precompile operation
all you will need is to modify the MainForm_Load() procedure in the following way:
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ConfigFilename As String = DefaultConfigFilename
Dim AutoRun As Boolean = False
Dim cla As String() = Environment.GetCommandLineArgs
If cla.Length > 1 Then
If cla(1).ToLower = "-autorun" Or cla(1).ToLower = "/autorun" Then
AutoRun = True
If cla.Length > 2 Then
ConfigFilename = cla(2)
End If
Else
ConfigFilename = cla(1)
End If
End If
ConfigOpt.Initialize(ConfigFilename)
ReadConfigValues()
Me.Text = Application.ProductName & " - " & ConfigFilename
ConfigToBeSaved = False
If AutoRun Then
cmdPreCompile_Click(Nothing, Nothing)
End If
End Sub
About your question number 2:
In order to make the tool execute multiple WFA, we need to modify the current concept of "Start with this Web Form Authentication request" checkbox. Maybe the best solution is to create a special syntax for specific lines in the URLs.txt file (to be manually edited) where more [Login URL / POST parameters] combination are specified in particular point of the URLs-to-be-visited sequence. Then, a simple modification in the "Main loop for hitting web requests taken from the URLs file" procedure is needed to manage the new case.
If you need just two or three WFA (followed by - I suppose - a set of child pages to be visited), my suggestion is to:
- implement the solution for question 1;
- prepare two or three appropriate config files, equipped with corresponding "URLs" files;
- execute (in a batch) ASPdotNETprecompiler.exe more times, sequentially, with the different configurations.
Hope this helps.
Cheers, AV
|
|
|
|
 |
|
 |
Thank you for your excellent and timely response, Alberto. I really didn't expect one since the last post here was over two years ago.
I modified the MainForm_Load() procedure as written (copy-and-pasted lines from Dim ConfigFileName... to last End If) in MainForm.vb.
I wasn't sure if I should overwrite the existing procedure or append to it. At first, I overwrote the existing procedure and when I received the behavior listed below, I then tried appending the new code to the existing. I separately ran both with the different execution variations from the CLI. In both cases, the resulting behavior was the same.
Behavior:
1. All execution variations opened the ASP.NET precompiler GUI but did not run the application.
2. All execution variations loaded the Untitled configuration file, even when others were named.
I guess we're thinking alike as far as question number 2. Your solution is exactly what I was thinking if the tool could be made to use command-line arguments.
|
|
|
|
 |
|
 |
Hi.
The code included in my preceding post is intended to "replace" the original content of MainForm_Load() procedure.
Maybe you're compiling the project with a newer version of Visual Studio or of the .NET Framework? The original code was for VS2003 and .NET 1.1 (and I only tested the proposed modifications on that original target).
Let me know, and we'll address the issue.
Ciao, AV
modified on Wednesday, August 6, 2008 11:49 AM
|
|
|
|
 |
|
 |
Ah, I thought something like that might be the case. The specific .NET Framework version we're using is v2.0.50727.
thanks
|
|
|
|
 |
|
 |
I actually converted the solution to VS2005 / .NET 2.0, I applied the modifications to Form_Load, and I found it working... Hence I find strange it is not working for you.
Are you sure you're launching the EXE having set the OS default directory to the one hosting the EXE itself, so that it is able to retrieve the config and URLs files correctly?
AV
|
|
|
|
 |
|
 |
Are you familiar with "The Simpsons" in Italy? Just call me Homer. DOH!
Not having programmed since college, I forgot that I needed to rebuild the executable after modifying the source code.
After converting the solution, applying the modifications, and rebuilding (DOH!) the executable, it works as advertised.
Is there a way to close the Main form from the command line after it's finished pre-compiling?
|
|
|
|
 |
|
 |
Homer,
to automatically close the application when autorun mode finished its work, just modify these lines:
If AutoRun Then
cmdPreCompile_Click(Nothing, Nothing)
End If
in:
If AutoRun Then
cmdPreCompile_Click(Nothing, Nothing)
Application.Exit()
End If
Cheers, AV
|
|
|
|
 |
|
 |
That's perfect.
I've generated a simple batch file to start (from a Windows GPO) at user logon. It's set to run twice with a different WFA in each. It executes, precompiles, stops, and exits without user interaction.
Perfect.
Grazie mille, Alberto, for all of your time, effort, and patience.
|
|
|
|
 |
|
 |
Once the precompilation is performed, will i need to recompile everytime I restart IIS?
Or do thecompiled images expire if the application is idle for some time?
What if the application uses a number of DLLs (some APIs or such) deployed in the bin folder?
Thanks in advance for a response.
RC
|
|
|
|
 |
|
 |
Q: "will i need to recompile everytime I restart IIS?"
A: Sure. Any compiled code resulting from the JIT compilation is discarded when:
- IIS is restarted;
- the Application Pool serving your web app is stopped or restarted;
- web.config is modified (-> Application Pool restarted)
- bin folder is modified (-> Application Pool restarted)
The assemplies DLL deployed in the bin folder contain MSIL code (resulting from the first compilation of source code by the standard language compiler), and they also need to be JIT-compiled to obtain native code.
The only option I know to have native pre-compiled code already ready for execution ad any time is following these two steps:
- developing a strongly-named DLL assembly to be installed in GAC;
- using NGEN.EXE (.NET Framework SDK tool) to produce a native code, compiled image in the GAC.
AV
|
|
|
|
 |
|
 |
Any hints as to how to get the appropriate viewstate? I've tried copying and pasting from View | Source, and actually GETting the login URL and parsing out the viewstate before doing a POST -- I just keep getting invalid viewstate error messages.
EDIT: Never mind. Just forgot to UrlEncode() the __VIEWSTATE value. Oops.
|
|
|
|
 |
|
 |
Yes, the only trick to keep in mind is to correctly encode special chars eventually found in the VIEWSTATE.
|
|
|
|
 |
|
 |
It's a great application!
It runs well for localhost but it gives me "The remote server returned an error: (401) Unauthorized." error message for each entry in LogFile.htm, althogh I do have admin right on remote servers. Any security settings I need to take a look at?
|
|
|
|
 |
|
 |
The LogFile was initially conceived in an HTML format just to be easily readable with a local browser, being ASP.NET Precompiler thought as a client application. If you need to access to LogFile.htm from a remote client, you simply need to publish it on a web site or to put in on a file share, as you would do with any static HTML file to be published.
|
|
|
|
 |
|
 |
Hi,
Thanks for a great article. However, I am getting the same 401 error on localhost. It fails on line
' Retrieve the response
wres = CType(wreq.GetResponse(), HttpWebResponse)
I even tried adding
Dim netCredential As NetworkCredential = New NetworkCredential("mark", "password") ' "CORP")
wreq.Credentials = netCredential
Am I missing something in the web.config? Please help.
|
|
|
|
 |
|
 |
try adding this line before adding any other properties
' Set credentials to use for this request.
wreq.Credentials = CredentialCache.DefaultCredentials
|
|
|
|
 |
|
 |
which is straight after the HttpWebRequest is created from the current URI
wreq = CType(WebRequest.Create(URI), HttpWebRequest)
' Set credentials to use for this request.
wreq.Credentials = CredentialCache.DefaultCredentials
|
|
|
|
 |
|
 |
Hi,
Can the above approach be used for a webservice asmx file.
The webservice is already compiled into a dll file in bin folder.
Let me know if there is a gap anywhere.
Anshuk Jain
|
|
|
|
 |
|
 |
Hi.
I'm not 100% sure and some tests are needed, but I think the answer is: yes, you can use this approach for Web Services.
Also the WebToucher described in
http://weblogs.asp.net/cweyer/archive/2003/02/07/2013.aspx
targets in the same way .ASXP files and .ASMX files.
Of course, you'll need to edit manually the URLs list (or modify the code that produce it in the "ASP.NET precompiler") to include .ASMX files also.
Let me know if it works!
|
|
|
|
 |
|
 |
Hi,
Thanks for your response.
I got the answer myself. I increased the time out of the connection to 5 minutes. Now its working.
|
|
|
|
 |