Hi, If i try to start an Asp.NET page by clicking the shortcut 'view in browser' it opens IE but it shuts it down instantly again. What am I missing? Thanks in advance!
Yustme
Posts
-
"view in browser" shortcut -
check if 5 min have passed[quote] I suggested to add logging statements and debug. [/quote] How different would that be when I used the debugger? [quote] And I told you MinValue was unrelated to the bug, but would allow for simpler code. [/quote] I still expected that something would change, not that it would solve the bug. [quote] Now solve your problem, don't wait to be spoon fed. [/quote] I could say that programming isn't like boxing, where you tell me a few words like 'you can take him down, you're stronger' while i know i'll get my ass wooped by this guy called Muhammed Ali (hypothetically, i'm fighting him in the ring).. Instead, you know, a few posts back you pointed me out that there is a quideline for asking questions. Did you know there is one for 'answering questions' too? A small quote from that guideline: [quote] Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.. [/quote] I'm not asking someone to do my work, pointing me in the right direction is more the enough!
-
check if 5 min have passedI think you miss understood my 'very fast'. Instead of 5 min, 5 sec. this is the loop, which is not in that function:
private void RestartAfterXMin() { while (this.AtLeastXMinutesHavePassed(5)) { Thread.Sleep(1000); if (this.stopRequested) return; } this.AutoStop(); Application.Restart(); }
It's initialized with minvalue, nothing changed. -
check if 5 min have passedI pass 5 min to this function:
DateTime lastTimeCommandWasUsed = DateTime.MaxValue;
private bool AtLeastXMinutesHavePassed(int xMinutes) { // Check if "x" minutes have elapsed DateTime currentTime = DateTime.Now; bool allowUse = false; if (lastTimeCommandWasUsed == DateTime.MaxValue) { allowUse = true; } else { TimeSpan elapsedTime = currentTime - lastTimeCommandWasUsed; allowUse = elapsedTime.TotalMinutes > xMinutes; } // Return status and keep track of new last used time if (allowUse) { lastTimeCommandWasUsed = currentTime; return true; } return false; }
And it returns very fast 'false'. After debugging it, it seems to check for seconds instead of minutes. Can't figure out what is going wrong.
-
check if 5 min have passedI know how... But obviously, I'm doing something wrong. So I thought another developer could help me out here...
-
check if 5 min have passedHi, How can I check if 5 minutes have passed with the datetime object? I've tried a few things, but none of them worked for me. Thanks in advance!
-
get the stream writer of the webbrowser controlIm already filling the form's manually in the webbrowser control. My idea why the login fails is because of the 'salt' it adds after the password. And it gets the salt from the DB. If i could fill in the forms programmatically with webresponse and request, would be great. This way, i dont have to load anything, which takes a lot of time.
-
get the stream writer of the webbrowser controlGetting html code of a topic in a vbulletin forum. If you're not logged in, you're not allowed to view the topic. I can't log in with the response class. This was my try:
private string login(string url, string username, string password)
{
string values = "vb_login_username={0}&vb_login_password={1}";
values += "&securitytoken=guest&cookieuser=checked&do=login";values = string.Format(values, username, password); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = values.Length; req.Timeout = 10000; CookieContainer a = new CookieContainer(); req.CookieContainer = a; System.Net.ServicePointManager.Expect100Continue = false; // prevents 417 error using (StreamWriter writer = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII)) { writer.Write(values, 0, values.Length); } this.response = (HttpWebResponse)req.GetResponse(); StringBuilder output = new StringBuilder(); foreach (var cookie in response.Cookies) { output.Append(cookie.ToString()); output.Append(";"); } return output.ToString(); }
</pre>
-
get the stream writer of the webbrowser controlYes i can get the html code from the page. But i need to navigate to it first. And there are a lot of pages to walk through.
-
get the stream writer of the webbrowser controlIdeally would be using the response class. Its much faster. But i can't log in on a website with it. I got a multithreaded application. When entering the event: WebBrowserDocumentCompletedEventArgs , another thread already navigated to another page. So i'll lose the last page where the webcontrol navigated to. Making the threads sleep a few seconds, doesn't help either. All i'm trying to get is the page content in html format.
-
get the stream writer of the webbrowser controlI thought that's the one i needed too. But where would i put the url to navigate to another url with it?
-
get the stream writer of the webbrowser controlHi, How can I get the 'pointer' of the stream writer the webbrowser control uses to navigate to websites? Thanks in advance!
-
safely end a threadHi, You're right, About an hour ago i got an else statement after that if-statement with a return. I'll use your suggestion. Saves me some line of codes :P Thanks!
-
safely end a threadHi, I didn't abort the thread. That was just 'speaking'. I know, i check its state on different places periodically. The code has grown too big to post it. I've reduced it now. I didn't see your post yesterday!
-
safely end a threadYes I'm sure. The variable gets checked alright. But it doesn't seem to stop it. Here is that thread i'm talking about with the code:
private void FileComparerThread()
{while (this.stopRequested != true) { for (int i = 0; i < Directory.GetFiles(this.dest).Length; i++) { string\[\] filePaths = Directory.GetFiles(this.dest, "\*.txt"); for (int j = 0; j < filePaths.Length; j++) { // check if btnCancel has been pressed if so, end this thread. if (this.stopRequested != true) { // check if file names are not the same: if (filePaths\[i\].ToString() != filePaths\[j\].ToString()) { bool comparedFiles = this.FileCompare(filePaths\[i\].ToString(), filePaths\[j\].ToString()); // move 1 file if they are both the same to another directory if (comparedFiles) Directory.Move(filePaths\[j\], Path.Combine(this.dest2, Path.GetFileName(filePaths\[j\]))); } } } if(filePaths.Length > 3) File.Move(filePaths\[i\], Path.Combine(this.dest, Path.GetFileName(filePaths\[i\]))); Thread.Sleep(5000); } } }
And then I got a this.FileCompare() function that checks 2 files for equality thats it. I've done some big time debugging. Its just looping those for statements. Even though the stopRequested = true. It's not comming out that for statement.
-
move a file from one directory to anotherHi Luc, It seems that the files which are moved, are somehow messed up. - If i try to open it, it's empty and ms windows is 'asking' me if i want to create a new file. - If i try to delete the file, windows is 'telling' me that the file "is no longer located in the-file-path". I was hoping you could help me out here.
-
safely end a threadHi, What do I need to do to end the thread after the Join? The 3rd thread has a while loop and in side that while loop i got a nested for statement. One for statement in another one. I check for the volatile variable in my while loop. And once more inside the deepest for statement. That should be enough right?
-
safely end a threadHi, I'm trying to end 3 threads in a save way. I can get 2 threads to stop, but the last one doesn't seem to abort. My try:
// Volatile is used as hint to the compiler that this data
// member will be accessed by multiple threads.
private volatile bool stopRequested = false;this.stopRequested = true;
// Use the Join method to block the current thread
// until the object's thread terminates.
this.thdPageContent1.Join();this.thdPageContent2.Join();
this.thdFileComparer.Join();
After the thdFileComparer thread, i got a messagebox that 'tells' me the threads are stopped: MessageBox.Show("Threads stopped successfully"); Any idea what I might be doing wrong? Thanks in advance!
-
move a file from one directory to anotherSo you're saying i have to pass the same file name to the destination argument too?
-
move a file from one directory to anotherLuc Pattyn, I fixed the problem. I found this site: http://www.devnewsgroups.net/dotnetframework/t1557-file-move-file-copy-exception.aspx[^] And: Jacky Kwok's reply to someone else's post did the trick. But I don't quite understood what he said. A quote from what I mean: [quote] The "BackUpPath" in both "Copy" and "Move" in your code are directory only. However, the "File.Copy" and "File.Move" require it is filename. [/quote] If I understand this correctly, File.Move wants in both arguments a File name like this: File.Move(file1, file2); Isn't that odd? I'm trying to move a file from one directory to another. But here, you're moving a file to another file?