|
This document is outdated.
If you cause a stack overflow yourself (outside a catch block) (not throwing the exception mind you, but real unbounded recursion) VS will stop and show you the stack.
Many a times it helped me in the recent past!
Otherwise yeah, one could never catch and terminate such an exception. I knew that too. Doesn't help though!
|
|
|
|
|
Actually, when you think about it, actually managing to catch an exception in an exception handler that is itself creating a stack overflow, well, that would be impressive.
|
|
|
|
|
Perhaps, indeed.
But that would still be handy!
|
|
|
|
|
I'm using VS2017 and it works as expected
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I'm using VS2017 and it works as expected That means it crashed
It does not solve my Problem, but it answers my question
modified 19-Jan-21 21:04pm.
|
|
|
|
|
Are you catching exceptions when they are thrown or only after they are dealt with?
If it is the latter, I think that even if you want to catch StackOverflowException's, it will not work because there's no more stack to let you do anything and it is probably using something like Environment.FailFast().
Environment.FailFast Method (String) (System)
|
|
|
|
|
Paulo Zemek wrote: Are you catching exceptions when they are thrown or only after they are dealt with?
What does that means? I mean what does "catching exception after they are dealt with" means?
|
|
|
|
|
You can debug exceptions when they are thrown. This means you stop even if there's a catch block that's going to "eat" the exception.
Or, you can debug only exceptions that are uncaught or are rethrown. In this case, if there's a catch clause, you will not see the exception until it is rethrown (if it ever is rethrown).
Usually on the second case, an exception that kills the application will not give you a chance to debug it. On the first case, you usually have that option (and for an exception throwing another exception, throwing another exception you would be bothered thousand of times before the app is killed).
|
|
|
|
|
I am doing a lot of computational maths work at home at the moment and, just for giggle, I thought of writing the following method. Code behave as incorrectly as expected!
static void Main(string[] args)
{
var e = 1e18;
Console.WriteLine(IsEven(e));
Console.WriteLine(IsEven(e + 1));
Console.WriteLine(IsEven(-e));
Console.WriteLine(IsEven(-e + 1));
}
bool IsEven(double d)
{
if (d < 0) return (d % 2) > -1;
return (d % 2) < 1;
}
|
|
|
|
|
What makes this even nicer is that both 1.0e+18 and 1.0 are exactly representable as a double, but their sum isn't. A nice demonstration of one of the pitfalls of floating-point arithmetic.
Ad astra - both ways!
|
|
|
|
|
ha, yeah, it's better than summing up 0.1 10 times, since 0.1 is an approximation to start with...
|
|
|
|
|
When you start with approximations...
You should conclude with "apporximately correct" = "correct"
There are ONLY Zeroes and Ones... Everything else is up for interpretation!
|
|
|
|
|
01001100 01101001 01101011 01100101 00101100 00100000 01110100 01101111 01110100 01100001 01101100 01101100 01111001 00100000 01101101 01100001 01101110 00100001
|
|
|
|
|
No finer compliment to a response has EVER been paid...
Thank You!
|
|
|
|
|
|
Damn, I had to quickly write a program to do that, if only I had known!
|
|
|
|
|
I must be old! I read that fairly quickly. Years spent eyeball reading punched paper tape. ASCII brain still works; I think I've lost baudot.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Either use Math.Round , or convert the value to a decimal type before performing math, and then back to a double after performing math.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
lol
initially I was wondering what was your point.. but I realise now it's subtle sarcasm, got me, hahah!
|
|
|
|
|
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
First of all, the code is super insecure.
This code allows anyone to hit a URL on my web site and create a user directory and one html file (which I fill in with their user name).
** EDIT **
I've implemented SSL on the site (as of 2018-04-25) so you can use the HTTPS version to try it if you like:
https://newlibre.com[^]
** END EDIT **
Usage
I've posted this at my web site : NewLibre.com[^]
To try it out you just hit : http://newlibre.com/api/values/<username> where <username> is a string representing the user name you'd like to create. It cannot include characters that don't work in a directory (because it creates a directory based upon your user name).
Sample
Here's a sample you can try : http://newlibre.com/api/values/superstar
If someone gets there before you, it simply notices that the directory and file is already created and redirects you there.
What Happens
When you navigate to the URL (get) the system:
1. creates a directory under my web site named after your username
2. generates a default html file with your user name in it
3. redirects you to the newly created page and loads it.
I'm Being Absurd
Isn't this absurd!?! I'm letting you navigate to a URL and generate a new folder and html page on my web server.
I know this opens me up for everyone create a new folder and just being mean-spirited but this is a prototype and I'm amazed at how simple the code is.
Also, they are created in a subdir and I will just delete the subdir.
I hope you find this interesting (and Weird & Wonderful).
This Is all The code it takes to do that
[HttpGet("{userName}")]
public HttpResponse Get(string userName)
{
var currentDir = Directory.GetCurrentDirectory();
DirectoryInfo di = Directory.CreateDirectory(Path.Combine(currentDir,@"wwwroot\allUsers\",userName));
string allHtml = $"<!doctype html><html><head><title>newlibre\\{userName}</title></head><body>newlibre\\{userName}</body></html>";
string htmlFileName = Path.Combine(di.FullName, $"{userName}.htm");
if (!System.IO.File.Exists(htmlFileName))
{
System.IO.File.AppendAllText(htmlFileName, allHtml);
}
var newUrl = "http://" + HttpContext.Request.Host + "/allUsers/" + userName + "/" + $"{userName}.htm";
Response.Redirect(newUrl);
return Response;
}
EDIT
I've altered the default page which is generated when you enter your userName, so it now looks like :
https://i.stack.imgur.com/rXxXB.png^
The new template that is created loads the daily dilbert strip!!
I hope you find that quite cool.
Also, if you type a dilbert.com daily strip link and click the button it will get that one and display it on your page (ie link will be like http://dilbert.com/2018-04-01)
New Content Each Day
Also, when you visit your page each day the newest dilbert will be displayed.
Although depending upon browser, it may take a manual refresh.
EDIT 2 - New Feature
I've now made it possible to generate your new (sub) web site based upon your user name by :
1) entering your user name in the text box
2) pressing the [Create UserName] button.
I simply added it at the top of the default page (which is ugly)
https://i.stack.imgur.com/zrgDW.png[^]
So now you can just go to the main web site (NewLibre.com[^]) and try it out.
I Know
This is getting ridiculous and needs to be an article. This is the prototype to something much larger.
EDIT 3 - More features
I now add a little message that the home page is created for the new user.
It looks like :
https://i.stack.imgur.com/Ivwr1.png[^]
I'll stop now.
I'm far enough with the prototype that it shows me what I can do.
More to come with a real article soon (hopefully).
modified 25-Apr-18 13:46pm.
|
|
|
|
|
You might want to check for invalid file name characters in the username. At the moment, I suspect it might be possible to use some version of "..\" to put files in a parent folder.
I've tried a couple of versions which don't seem to have worked. But if you see a "test" folder and "test.htm" file in your "wwwroot" folder, then it's trivial to hack.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I looked and I don't see any new ones, but I will definitely implement some checks against that.
Thanks for mentioning it.
I was able to create one with spaces in it like:
http://newlibre.com/api/values/this is a good test
Wow.
|
|
|
|
|
It works ! but I would like a funny picture in the created website 
|
|
|
|
|
I've implemented your idea. A funny pic...ala the daily dilbert.com
your page will now look like:
https://i.stack.imgur.com/rXxXB.png^
The new template that is created loads the daily dilbert strip!!
I hope you find that quite cool.
Also, if you type a dilbert.com daily strip link and click the button it will get that one and display it on your page (ie link will be like http://dilbert.com/2018-04-01)
I've deleted the old user directories so try creating yours again and you will see this.

|
|
|
|