galratner

Stories submitted by galratner

Using ASP.NET MVC 4, ApiControllers and SQL Server 2012(galratner.com)

submitted by galratnergalratner(334) 4 days, 16 hours ago

ASP.NET MVC continues to innovate and in its current version (4) it offers support for Web APIs. Today we are going to examine a real life scenario of using Web APIs along with MVC 4 as we are utilizing the Google Earth plug-in to mark a defined area and SQL Server 2012 geography type to help us persist and calculate GIS data. In our example we are going to mark an area on the globe using a polygon, calculate the center of the area, find all of the coffee shops closest to the center of the area and arrange them by distance. We are going to mark them on the map as well as show a full list including ranking. read more...

add a comment |category: |Views: 176

tags: another

Reloading a Razor WebGrid after Ajax calls using a partial view(galratner.com)

submitted by galratnergalratner(334) 5 months, 25 days ago

f you are using Razor and MVC you probably make some use of the built in controls in System.Web.Helpers. WebGrid, located in the Helpers assembly, was created for WebMatrix’s Razor Web Pages and landed itself nicely to Razor views in MVC. WebGrid, much like ASP.NET’s ListView control, is designed to display a data driven HTML table on the screen. It has support for paging, sorting and column customization. In this article, we will be taking a quick look at loading a WebGrid with data, both as a part of a page and as a standalone AJAX call. AJAX calls can occur after a page load or sort change and as a part of the interaction of a user with the data on the grid. Let’s begin by making a view. The view will contain the body of the page rendered in the @RenderBody() section of the main layout. In our case the grid will reside in the index page and the index view will simply look like this: read more...

add a comment |category: |Views: 53

tags: another

Give your old ASP.NET validators a makeover with jQuery TOOLS(galratner.com)

submitted by galratnergalratner(334) 6 months, 18 days ago

If you have been working with the default validators in ASP.NET for a while you are probably used to the plain old look they create on your page and while you can rework the way they look, ASP.NET validators are essentially a Label. They are unable to change the appearance of other elements or run scripts without a complete page postback. jQuery TOOLS is a jQuery based UI library you can find here. jQuery TOOLS contains a validator as a part of its form tools. The jQuery TOOLS validator is based on HTML 5 and CSS standards and has the ability to animate, change the appearances of the element it is validating, support multiple languages and more. read more...

add a comment |category: |Views: 11

tags: another

Deep dive into the LinkedIn API: Use C# to search for your dream Job(galratner.com)

submitted by galratnergalratner(334) 7 months, 12 days ago

LinkedIn has an extensive API designed to access almost every aspect of the site. Developers can access People and Connections, Groups, Companies, Jobs, Social Stream, Communications and more. There are two types of LinkedIn APIs: JavaScript based and REST based with the ability to connect the two. For example: you can log in with a JavaScript button and monitor your social updates using server based code. You can then send yourself summary emails with the updates. This is a deep dive into both APIs. We are going to be using the JavaScript login button, showing the user’s name using HTML. LinkedIn’s REST API uses OAuth authentication which we will utilize in order to get a new REST token. We will then re log in on the server and invoke the REST API, perform a jobs keyword search, return the results as JASON and show them to the user. read more...

1 comment |category: |Views: 9

tags: another

How to record Skype voice conversations in a WPF Program(galratner.com)

submitted by galratnergalratner(334) 8 months, 29 days ago

First let’s start at the end. If you are looking for free software to record Skype voice conversation, please skip to the bottom of this page and download the attached file. It contains a Windows Installer msi file and should install a recorder on your machine. read more...

add a comment |category: |Views: 6

tags: another

Secure user authentication with one way password hash(galratner.com)

submitted by galratnergalratner(334) 10 months, 21 days ago

eeping users passwords in your database is a part of almost every application, yet securing passwords is rarely being done correctly. I recently read an article by Coda Hale about the ineffectiveness of password salts. Coda Suggested using bcrypt to store passwords. He reasoned his argument by explaining bcrypt is extremely slow to compute, therefore making it slow to hack. I completely agree, however, I wanted to add another way of safely storing passwords in a more conventional way by hiding the salt in the hash. The idea wasn’t mine. It belongs to a DBA named Scott Hulberg. It’s pretty simple and for the sake of this blog post I am not going to implement it completely. I am going to prepend the salt to the password hash, making it invisible to a hacker. You can go further by writing an algorithm to plant the salt in the hash array as you see fit. Since the only way to match a one way hashed password is to use the salt we used to generate this hash, if a hacker cannot get to the salt, they cannot retrieve the original password. Let’s begin by composing the method to create our hash and prefix it with the salt: read more...

add a comment |category: |Views: 5

tags: another

Display your top selling products in ASP.NET using a Bubble Chart(galratner.com)

submitted by galratnergalratner(334) 10 months, 29 days ago

System.Web.DataVisualization contains 34 types of charts. The most common of them is the Column chart on which I already blogged about in Display a sales chart with ASP.NET Chart control and Linq to SQL. Today I am going to take our sales chart one step further and display the top selling products for the year. Since we have multiple products for each time span, I chose a Bubble chart. First let’s look at the data model: read more...

add a comment |category: |Views: 7

tags: another

Sharing memory session between servers(galratner.com)

submitted by galratnergalratner(334) 11 months, 25 days ago

Session variables hold per user information. Unlike cookies, sessions store information on the server rather than on the client. The client holds a session cookie with the client’s session ID and at the time of an HTTP request, the server accesses the client’s session ID and retrieves the session data. The default implementation of session has the web server holding the information in memory. This implementation as fast as it is has some drawbacks: Recycling your app pool or restarting IIS will abandon all of the sessions currently in memory. Sharing sessions between web servers is also not possible and when load balancing traffic between servers we need to resort to “sticky sessions”, a method in which all client requests will be redirected to the same physical server as the first request. This would enable us to still use default sessions, however, it will not solve the first issue I mentioned and we are still running the risk of overloading a server’s memory under heavy traffic load when some of our servers are slow to respond. read more...

add a comment |category: |Views: 4

tags: another

Spatial Search made easy with Google Maps API and SQL Server 2008(galratner.com)

submitted by galratnergalratner(334) 1 year ago

Spatial search is the process of searching locations nearby to a position in space. A good example of a spatial search would be finding all of the restaurants near your present location. With Google’s Maps API and SQL Server’s Geography data types we can build a quick spatial search in no time. In this little exercise I will be detecting the user’s location, displaying it on a map and suggesting nearby restaurants. Since not all browsers support the W3C standards I will also allow manual input of the user’s address. Spatial search relies on latitude and longitude which are the global position coordinates. The process of turning an address to a set of latitude and longitude coordinates is referred to as Geocoding read more...

add a comment |category: |Views: 17

tags: another

Consume an OData WCF Data Service as JSON with JQuery(galratner.com)

submitted by galratnergalratner(334) 1 year, 1 month ago

OData(Open Data Protocol) is an HTTP based protocol for querying and updating data using full REST syntax. The full specifications of OData can be found on http://odata.org WCF Data Services (formerly ADO.NET Data Services, formerly Project Astoria) is the .NET based implementation of OData enabled services. WCF Data Services can use an Entity Framework Context or any data model exposing at least one property that returns an entity set that is an IQueryable(Of T). The model must also implement IUpdatable. A sample http request to an OData service will look like: http://services.odata.org/OData/OData.svc/Categories(1)/Products?$skip=2 This example will get the products associated with the category identified by key value 1, starting with the third product. WCF Data Services is capable of returning data in multiple formats. The default format will be set based on the requesting client’s accept request header with an option to override the format using the $format query option. For example, this will return the results from the previous example in JSON format: http://services.odata.org/OData/OData.svc/Categories(1)/Products?$skip=2&$format=json read more...

add a comment |category: |Views: 52

tags: another

Four ways to utilize Entity Framework 4(galratner.com)

submitted by galratnergalratner(334) 1 year, 2 months ago

There is some confusion out there about a simple question: How can I use Entity Framework? Some developers have heard about reverse engineering models so I decided to write a quick preview to the main features of EF4. This isn’t an in-depth article, but, rather a visual summary of the main four scenarios EF can accommodate. If you are looking to utilize any of the scenarios described here you might need to seek further documentation and realize that development with Entity Framework is a vast subject and is beyond the scope of a single article. read more...

add a comment |category: |Views: 8

tags: another

Reading an Excel spreadsheet into dynamic objects(galratner.com)

submitted by galratnergalratner(334) 1 year, 2 months ago

Excel represents documents using Office Open XML (OOXML), a zipped XML based format developed for spreadsheet and chart representation. In this article I am going to demonstrate parsing an Excel spreadsheet and loading the data into a generic List. OOXML was incorporated into Office in 2007 therefore the following code will not work with older versions of Excel. read more...

add a comment |category: |Views: 16

tags: another

Never break the build again with an organized code base(galratner.com)

submitted by galratnergalratner(334) 1 year, 2 months ago

During my time developing for different companies one of the most common daily scenarios I encounter is helping a developer debug code. Going to some method’s definition, only to realize they can only view metadata and not actual code. The library is still internal, most likely developed by another department inside the same organization, however, it was added as an external DLL reference and to view the code they need to open another solution in another folder. Well this will work until the external code has been updated and since code is updated daily, the references must also be updated or the code base quickly goes out of sync, not to mention debugging the external binaries is very difficult. read more...

add a comment |category: |Views: 4

tags: another

Send a web page as an email with embedded images(galratner.com)

submitted by galratnergalratner(334) 1 year, 3 months ago

In email marketing, sending customized emails is a common practice. Emails containing special offers, shopping cart items or any other dynamic content, are usually tailored to the individual and are being sent either by request or as a part of a marketing campaign. This presents a challenge since email templates are usually being maintained by the marketing department and need to be simple to change, yet flexible enough for a programmer to add any dynamic data as needed. The solution can be reading a dynamic existing HTML or ASPX page and emailing a copy of it to the recipients. This blog post will show how to read the HTML content of a page, add the images to an email and send the email and images as an embedded resource so that the recipients will not need to view images hosted on an external server. First we need to read the page we are about to send. This can be a URL containing the customer’s email or unique ID for example: mydomain/salereceipt.aspx?SaleID=LKJGHIU read more...

add a comment |category: |Views: 12

tags: another

Getting around PathTooLongException on file move with Windows Native A(galratner.com)

submitted by galratnergalratner(334) 1 year, 3 months ago

If you ever got the error message “The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. “ you are probably aware that there is no practical way of moving files with long paths using System.IO.File. The solution is to use the Native Windows API. You can see the API here: http://msdn.microsoft.com/en-us/library/aa364232(v=VS.85).aspx Here is a little helper class I wrote to utilize the native API from .NET: read more...

add a comment |category: |Views: 6

tags: another

A simple fast configuration-less rolling file appender(galratner.com)

submitted by galratnergalratner(334) 1 year, 3 months ago

If you ever needed a simple logger and did not want to deal with the complexity of configurating Log4net or the enterprise library you might find this class useful. This is a single class, single file rolling file appender. Usage: To use this logger all you need to do is either add the class to your code or use the DLL as a reference. If you chose to use the dll you need to import it in your code as follows: read more...

add a comment |category: |Views: 13

tags: another