spam this
I’ve been rather happy with ASP.NET and especially with ASP.NET MVC. I’ve got to say that C# and especially Linq is just a plain pleasure to use. I have no issues with the programming side. Ever since I’ve gone from running my own Windows Server to using shared hosting it’s been one headache after another. Getting permissions set on a folder is like pulling teeth. Getting the host to set trust levels is more teeth pulling. Have an issue with a web app? I’m running out of teeth!
Comparing PHP to C# is sort of laughable. I really don’t like the syntax. I’ve actually gone so far as to avoid PHP by trying Ruby on Rails because it was suggested because the MVC architecture is supposedly similar to ASP.NET MVC. I’ve got to say that Ruby on Rails is just one hot mess. I can’t stand using any of the editors and using the console to generate a simple controller takes so long that I lose interest by the time it’s ready. The “Ruby way” is just nuts, too. The ability or desirability of putting the condition at the end makes absolutely zero sense. What is the difference between “if this occurs, do this” and “do this if this occurs”? Asking for help about Ruby on Rails online is like shouting in the desert. All the forums are dead. No replies. It was once suggested that I get on IRC for Ruby on Rails help. Really? IRC? Maybe I should just hook up a CB Radio while I’m at it. Better brush up on my ten-code.
I currently pay for shared hosting on an Apache server through site5.com and I’ve had maybe 2 issues totaling half an hour, if that. My shared Windows server constantly gives up and shuts down AppPools refusing to spool them up in a timely fashion. Getting crawled by Google and Bing at the same time just brings the server to it’s knees and I get emailed error reports at least weekly.
Basically, I’ve traded my “WHAT IN BLAZES” moments in programming for “WHAT IN BLAZES” moments in hosting. I can control my confusing moments so I’m strongly considering getting back into PHP and leaving the issues behind. I’ve been fighting it because of all the time and money invested in learning .NET and purchasing Visual Studio but I think in the long run to cut the Windows Server service and go back to Apache will make more sense.
I’ve got to give Microsoft a whole lot of kudos for Visual Studio. It really is that good. They also deserve applause for LINQ, it’s wonderful. In the end though, if I can’t keep a site rolling properly, and I can’t easily add a site to the block list (.htaccess makes this so very simple) then I’m just going to say goodbye and take the other path and relax.
Posted in Programming by Mark (01Apr12 @ 1942)
Trackback | Permalink | Comments Off
Open Trackback Alliance
To get your article listed below please visit this link and link up your best work.
The following articles do not necessarily represent the views of imaginekittymagazine.
- The Trouble With Angels: Prize Game Up At "Dead Guy"...
For those of you who aren’t regulars but may want a chance to win the prize T-shirt, you need to get on over to Dead Guy On The Sidebar and get your...
- Cao's Blog: “He’s our brother”...
Read this piece “Notes from a War Diary” by Ollie North. There are several little stories there, but the last one is the one that touched me the most....
- 123beta: Please Send Money...
Dear good person from North America, I’m an honest, hard-working Nigerian King, just waiting for my bank to release millions of dollars to me to help my family and...
- 123beta: Budda Bing Bang Boom...
Time to resurrect an oldie but a goodie… Dedicated to the flying Imams….
- 123beta: Open Trackback Weekend #29...
I hope everyone had a great Thanksgiving! Please feel free to leave a post and I’ll be sure to send a trackback your way. …
- The Business of America is Business: End It Like Beckham...
In a bid to boost its competitiveness, its image, and its gate receipts, Major League Soccer (MLS) is changing its rules. The rules concern not...
- Test Track: I got in a fight with my dad. :(...
I remember I was hammering on a fence in the backyard when my dad approached me. He was carrying a letter or something in his hand, and he looked worried. I continued...
- BRING IT ON: Mark 11:23-24
Mark 11:23-24 For verily I say unto you, That whosoever shall say unto this mountain, Be thou removed, and be thou cast into the sea; and shall not doubt in his heart,...
- Renaissance Blogger: Another Strike Against Children’s Innocence...
I don’t think I’ve seen anything that has bothered me as much as this toy being marketed to four and five year olds as a fitness product. From the...
- Committees of Correspondence: You can't always get what you want......
“The Lesser of two Evils” is a saying that has been cropping up in recent years. This is what is called a “cliche”. Cliches...
I’ve been having issues with Verizon DSL randomly shutting down and not coming back up for an unacceptable length of time. Strangely it only happens on the Vista machine in the house. None of the Macs have this issue.
I think I discovered the issue. I had changed my settings in Opera using about:config. I had the “Max Connections Server” and “Max Connections Total” set very high and what I think was happening was that I was hitting the DNS server too many times and perhaps it was considered a ping flood or something similar.
I guess you can overdo browser optimization.
Posted in Random by Mark (11Jan11 @ 1951)
Trackback | Permalink | No Comments
I helped a friend set up his Shoutcast server for his web site. It was a fun project and I really enjoyed it. I may have to install one for myself one of these days.
Check out Polish New Castle for polka goodness 24 hours per day.
Posted in Programming by Mark (24Dec10 @ 1134)
Trackback | Permalink | Comments Off
- Create a new MVC applictaion
- Open /Views/Shared/Site.Master
- <script src=”/Scripts/script.js” type=”text/javascript”></script>
- This doesn’t point to anything yet
- Open Global.asax
- Add a MapRoute
- routes.MapRoute(“Javascript”, “Scripts/{scriptFile}.js”, new { controller = “Scripts”, action = “Index”, scriptFile = “script” });
- Now /Scripts/script.js points to Script/Index
- Add a view for CssController/Index
- <%= Url.Content(“~/Content/test.jpg”) %>
- Change contenttype in page directive of Views/Scripts/Index.aspx to “text/javascript”
- That should do it.
Adding strongly typed objects to javascript is now simple to achieve and instead of adding javascript to the <head> in your master page you can just have a dynamically generated and cached .js file.
You may download a sample MVC2 project here.
Posted in ASP.NET, C#, MVC, Programming by Mark (15Aug10 @ 1407)
Trackback | Permalink | No Comments
I’ve been considering the usefulness of adding a CSS management system to my CMS that I’ve been working on. Here are the steps I’ve taken to implement it.
- Create a new MVC applictaion
- Open /Views/Shared/Site.Master
- <link href=”/Css/Site.css” rel=”stylesheet” type=”text/css” />
- This doesn’t point to anything yet
- Open Global.asax
- Add a MapRoute
- routes.MapRoute(“Css”, “Css/{cssFile}.css”, new { controller = “Css”, action = “Index”, cssFile = “Site” });
- Now /Css/Site.css points to Css/Index
- Add a class Css.cs to Models
- Add public string Body { get; set; }
- Add public string Width { get; set; }
- Add public string Background { get; set; }
- Add definitions as desired
- Add a view for CssController/Index
- Make it strongly typed with CSScontrol.Models.Css as the model
- Change contenttype in page directive of Views/Css/Index.aspx to “text/css”
- That should do it.
I’m not sure that I’m convinced of the usefulness of this idea but it’s possible and easy to implement in your ASP.NET MVC project. The possibility of using variables in a CSS file is intriguing.
You may download a sample of the MVC2 project here.MVC3 project here. Let me know if this is a good idea, a horrible idea or just a bit interesting.
Edit – I’ve added a Response.Filter to this to remove extra spaces, tabs, carriage returns/new lines, final semicolons and comments. It brought the 4.96kb file down to 2.74kb. It can be enabled/disbled in Web.config using appSettings key CompressCSS (bool)
Posted in ASP.NET, C#, MVC, Programming by Mark (26Feb10 @ 0946)
Trackback | Permalink | 5 Comments
OK, I named this post that so that perhaps google will pick it up and those new to CSS will find this post.
There is a really good reason that there are no tutorials on the internet concerning how to add content (a site menu is the most common request) to all the pages on your web site using CSS. That’s because CSS doesn’t control content. It controls styling and nothing more. You don’t use styling to add content.
Why not look into some sort of server side includes. PHP includes will handle the situation. ASP.old can handle it but don’t use it unless you have no other choice (and you do). If you’re really fancy and modern and handsome and awesome you can just use ASP.NET MasterPages and/or User Controls.
To wrap it up, CSS doesn’t do that. Stop asking about it! Thank you.
Posted in Programming, Web design, Web standards by Mark (23Feb10 @ 2119)
Trackback | Permalink | No Comments
Recently someone challenged me to write a server-side method for finding the current season and changing a style sheet accordingly.
The first step is deciding how to differentiate the seasons. I figured to use the day of the year so that astronomically Spring begins on March 21st, the 80th day of the year. Summer begins on the 172nd day, Autumn, the 266th and Winter the 355th. Of course, on a leap year add one day to each, 81, 173, 267 and 356.
Now to find the day of the year use the DayOfYear property. Also, use the IsLeapYear property to take a day away on leap year if the current day is after February 28th (the 59th day of the year). This is easily done by converting the bool IsLeapYear to an Int32 giving a 0 during non-leap years and 1 during leap year.
int doy = DateTime.Now.DayOfYear - Convert.ToInt32((DateTime.IsLeapYear(DateTime.Now.Year)) && DateTime.Now.DayOfYear > 59);
Then find the current season using a few nested ternary operators (I like ternary operators)
string currentSeason = String.Format("{0}.css",((doy < 80 || doy >= 355) ? "winter" : ((doy >= 80 && doy < 172) ? "spring" : ((doy >= 172 && doy < 266) ? "summer" : "fall"))));
I use this in the head of my MasterPage:
<link rel="Stylesheet" runat="server" id="seasonSheet" type="text/css" />
So all I have to do to add the correct style sheet for the current season is this:
seasonSheet.Attributes.Add("href",currentSeason);
Now a stylesheet named spring.css, summer.css, fall.css or winter.css will be added to your rendered MasterPage.
I hope you’ve found this helpful.
Posted in ASP.NET, C# by Mark (28Dec09 @ 1518)
Trackback | Permalink | No Comments
While reading about a recent question concerning @@Identity and the reasons to use SCOPE_IDENTITY() instead I experimented with LINQ to get the SCOPE_IDENTITY() results.
using (var dbc = new siteDataContext())
{
dbc.Log = Console.Out;
repertoire newSkill = new repertoire
{
skill = "a new item"
};
dbc.repertoires.InsertOnSubmit(newSkill);
dbc.SubmitChanges();
Console.Write(newSkill.id.ToString());
}
It seems that calling the id column of the inserted object gives you the SCOPE_IDENTITY(). Here is the SQL Log:
INSERT INTO [dbo].[repertoire]([skill])
VALUES (@p0)
SELECT CONVERT(Int,SCOPE_IDENTITY()) AS [value]
-- @p0: Input NVarChar (Size = 10; Prec = 0; Scale = 0) [a new item]
-- Context: SqlProvider(Sql2008) Model: AttributedMetaModel Build: 3.5.30729.1
Posted in ASP.NET, C#, LINQ, Programming by Mark (31Oct09 @ 1058)
Trackback | Permalink | No Comments
WebAIM‘s Screen Reader Survey, conducted December 2008 to January 2009, is a very interesting read. Yet another nail in the Flash coffin but surprisingly Frames are deemed easy to use by nearly 60% of screen-reader users.
Give it a quick look. Comments open.
Posted in Web design, Web standards by Mark (10Feb09 @ 2033)
Trackback | Permalink | No Comments
I was working on a project and just on a whim decided to try out some of .NET’s AJAX controls. I chose a random page, added a ScriptManager, tossed in a TextBox and a CalendarExtender.
F5. Page shows up. Javascript error:
Line: 121
Char: 1
Error: 'Sys' is undefined
Code: 0
Url: http://localhost:49329/admin.aspx
Hmm.
Try a new project. Add a ScriptManager, tossed in a TextBox and a CalendarExtender. Works fine. Huh?
I go through the Web.Config files of the two. Nothings changed except the version number on everything:
non working: Version=3.5.0.0
working: Version=1.0.61025.0
Ah ha! That must be it. I reset the working project as a 3.5 app and run it. I was so sure it was going to fail. Nope. Worked fine.
Must be something else. *grumble*
I start taking pieces out of my existing app and when I came to the Global.asax I took out the RouteTables and AJAX comes to life! FINALLY!
Here is what I had:
Global.asax
protected void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RegisterRoutes(RouteTable.Routes);
}
private static void RegisterRoutes(ICollection<RouteBase> Routes)
{
RouteTable.Routes.Add(
new Route("{Parameter}/{pageID}", new RouteHandler()));
RouteTable.Routes.Add(
new Route("{Parameter}", new RouteHandler()));
}
With my routing handler file showing this little gem:
RouteHandler.cs
string virtualPath = string.Format("~/{0}.aspx", pageName);
return (Page)BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(Page));
So basically it was swiping the file extensions from my httpHandlers and replacing them with .aspx meaning they were not found.
Web.Config
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpHandlers>
To handle the situation I added the following to Global.asax:
Global.asax
protected void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RegisterRoutes(RouteTable.Routes);
}
private static void RegisterRoutes(ICollection<RouteBase> Routes)
{
RouteTable.Routes.Add(new System.Web.Routing.Route("{resource}.axd/{*pathInfo}",
new System.Web.Routing.StopRoutingHandler()));
RouteTable.Routes.Add(new System.Web.Routing.Route("{service}.asmx/{*path}",
new System.Web.Routing.StopRoutingHandler()));
RouteTable.Routes.Add(
new Route("{Parameter}/{pageID}", new RouteHandler()));
RouteTable.Routes.Add(
new Route("{Parameter}", new RouteHandler()));
}
I hope this helps.
Posted in ASP.NET, C#, Programming by Mark (30Jan09 @ 1614)
Trackback | Permalink | Comments Off
« Previous Entries
Amazon Wishlist
Hello, friends! I've decided to put my Amazon wishlist online. If you feel nice today you can purchase one of the items listed and it will be shipped to my door. My birthday is May 13th and I will gladly accept gifts for any Christian or Jewish holiday. Thank you for your support.