Tuesday, May 20, 2008
I have been developing applications using the Revit API (based on the .Net framework) for my workplace. I have been storing these applications on a network drive and having each user simply run them from there. This allows easy updating and easy deployment. Unfortunately, Microsoft have battened down the hatches when it comes to security for applications not running off your hard drive. There are "Security Zones" in .net (you can see these on most machines in Administrative tools in .Net Framework Configuration), Intranet is one of them. The security level on Intranet is very high, just below the Internet level! So, any application running off a network drive will have issues if it tries to do anything other than basic GUI functionality. This includes TCP Streams (SocketPermission) and File Access(IOPermission). We have a file server which stores our files and programs, I want anything on that server to be trusted fully. After some searching I found a very helpful blog from "ShawnFa", who is a bit of a .Net security guru. So then, I just made a script which does: echo y|C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\caspol.exe -m -ag 1.2 -url file://server/share/* FullTrust changing the server and the share to the ones you want to allow. Echo Y takes away hte need for the user to confirm. I've added the full path to the .net framework as the script didn't work for me without it, you might just need caspol.exe. But adding the full path gives you the ability to set it for different frameworks (.Net 1.1 applications don't use the .net 2.0 security I believe etc) Now I've dumped that in a startup script for my users, and all is good!
Sunday, May 18, 2008
This post is a little different to my usual posts, in that it's not overly technical. I recently discovered Twitter, after initially thinking it would be useless, I've been thinking of more and more good uses for it, particularly to do with the API and the SMS functionality. But one that I don't need to code, is to update your facebook status via SMS. All you need to do is create a Twitter account, setup the SMS section of it (really easy), and then in your facebook, add TwitterSync (There is another twitter app too, but it wasn't working when I tried it). You dont need to put in your password if your twitter is public (as they are by default), then just allow it to update your facebook status when it asks and you are set. If you use your twitter for things you dont want to show on facebook (I use it to send reminders to myself for when I get home), there is a section in setup to put certain characters that tell facebook that its not meant to be your facebook display. I put "Nf" as mine, but you could put anything. It would be good if they could do it the other way (ie only update facebook status if you put facebook as the first word or something), but I haven't found this feature (let me know if its there!) Then you are all set, be careful, you'll get addicted and flood your facebook with useless updates, remember, your friends don't care if you are buying new toothpaste!
Thursday, May 15, 2008
Just a quick post to remind people of the ASP.net life cycle. Most people learn this early on in their ASP.Net life, but it's something that can be overlooked and leave you slapping your head in frustration. Recently, I was working on a simple page that has some text box fields, which are pre-populated with a users details, you edit those and click submit, it submits the new details and refreshes the page, hopefully with the new details. My database updates didnt seem to work, I searched through my data access layer and business logic layer to no avail, then I slapped my head and mouthed a few curse words when I realized that I'd populated my text boxes in the Page_Load section, when really I should have done it on the OnPreRender or a similar event (or, as mentioned in comments, use the !Page.IsPostBack method, though this way would simply retain the data inserted into the text boxes from viewstate, I wanted it to regenerate it from the database to ensure my data was inserted correctly and in the format I wanted) To brush up on the events life cycle check out this article.