Wednesday, July 17, 2013
Thursday, February 9, 2012
Get Name of an Enumerable in VB.NET
Blog has been moved to:
http://robfine.com/aspnet/GetNameofanEnumerableinVBNET
Tuesday, November 8, 2011
AutoPopulate a Textbox Like Facebook
Blog has been moved to :
http://robfine.com/aspnet/AutoPopulateaTextboxLikeFacebook
Labels:
autocompletion,
autopopulate,
facebook,
tag,
Textbox
Saturday, October 29, 2011
99X Brouhaha Picture Gallery
Digits in Motion is very excited to be working with 99X on this year's 99X Brouhaha Fan-Driven Photo Gallery. Event attendees can share all their pictures from the night by adding them to http://99xbrouhahapix.com - with easy import integration from Facebook and Flickr, it only takes 3 clicks to share your pictures with others who attended. You can tag costumes, to make it easy to find yourself in others pictures or find costumes you liked.
99X Brouhaha Photo Gallery | Share and Search Pictures From 99X Brouhaha
99X Brouhaha Photo Gallery | Share and Search Pictures From 99X Brouhaha
Labels:
99x,
brouhaha,
facebook,
flickr,
integration,
photo gallery,
pictures
Wednesday, August 10, 2011
Wednesday, July 20, 2011
Thursday, June 9, 2011
Tuesday, May 31, 2011
Multiple Fields for HyperLinkField URL in DevExpress Gridview
Blog has been moved to :
http://robfine.com/aspnet/MultipleFieldsforHyperLinkFieldURLinDevExpressGridview
Friday, May 20, 2011
Add Custom Properties to ASP Membership User
Blog has been moved to :
http://robfine.com/aspnet/AddCustomPropertiestoASPMembershipUser
Monday, May 2, 2011
Friday, April 29, 2011
Friday, April 22, 2011
Thursday, April 21, 2011
Friday, April 8, 2011
Convert phone number string to digits only
Blog has been moved to :
http://robfine.com/aspnet/Convertphonenumberstringtodigitsonly
Labels:
convert,
digits,
format,
numbers,
phone,
RegEx,
Regular Expression,
regularexpressionvalidator,
Replace
Thursday, April 7, 2011
Wednesday, April 6, 2011
Pull API response using HttpWebRequest in ASP.NET (Yelp Example)
Many ASP.NET APIs will come with classes set up to help you easily pull information (such as Google, Facebook, YouTube, etc), but sometimes, such as in the case of Yelp, you'll need to connect to a URL to pull a JSON object or string.
Here's a quick and simple say to do this:
What we've done here is sent a HttpWebRequest out to ping the apiURL as defined by the first line of my Form_Load sub. In this case, I took a Yelp API url (you'll need to fill in the phone number, yelp api ID), but you can use any url. This particular Yelp one will return a serialized JSON Object that I can then parse out and use the information however I want.
Desired result of this HttpResponse:

After I post my request to Yelp, I can pull their response into a stream and display it to my web page using a literal, in my case, I've used a control named 'myLiteral'.
It's really that easy and fairly simple to adapt to any kind of response you'll get.
Here's a quick and simple say to do this:
Public Sub Form_Load() Handles Me.Load
Dim apiURL As String = "http://api.yelp.com/phone_search?phone=6785557743&ywsid=####-########_#######"
Dim uri As New Uri(apiURL)
If (uri.Scheme = uri.UriSchemeHttp) Then
Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
request.Method = WebRequestMethods.Http.Get
Dim response As HttpWebResponse = request.GetResponse()
Dim reader As New StreamReader(response.GetResponseStream())
Dim tmp As String = reader.ReadToEnd()
response.Close()
myLiteral.Text = tmp
End If
End Sub
What we've done here is sent a HttpWebRequest out to ping the apiURL as defined by the first line of my Form_Load sub. In this case, I took a Yelp API url (you'll need to fill in the phone number, yelp api ID), but you can use any url. This particular Yelp one will return a serialized JSON Object that I can then parse out and use the information however I want.
Desired result of this HttpResponse:

After I post my request to Yelp, I can pull their response into a stream and display it to my web page using a literal, in my case, I've used a control named 'myLiteral'.
It's really that easy and fairly simple to adapt to any kind of response you'll get.
Labels:
API,
asp.net,
httpwebrequest,
httpwebresponse,
web service,
yelp
Thursday, March 31, 2011
Issues When Migrating to IIS7: Default Documents and Images
I recently migrated all of my company's websites to a new server, upgrading from IIS6 to IIS7 in the process. There were several hurdles we had to jump in making the version change and I thought it may help others to learn from our experiences.

On our older server, we had many domains feeding into the same web application, yet each domain would set certain variables through the query strings of the default document of the site.
For instance, a domain "myExample.com" a default page "DefaultPage.aspx?e=29" would set all the variables necessary for portal #29.
With IIS7, we no longer have this luxury, and must only feed in a single filename, i.e. "DefaultPage.aspx"
One of my first thoughts was, ugh, am I really going to have to create a seperate landing page for EVERY domain linking into the site? As you'll read in the work-around, no. That's not the best way to do it. And as it turns out, it's not even possible. For every Home Directory you route to in IIS7, you have to use the same landing page for all websites pointing to that folder. So, if I have myExampleA.com and myExampleB.com both pointing to c:\inetpub\wwwroot\myExamples\ and I define myExampleA.com's default document to be WelcomeToA.aspx, then myExampleB.com will inherit the same default document. They have to be the same. Another big change for default documents when migrating from IIS6 to IIS7.
I've noted several people using URL Rewrites to solve this, but with an application as large as ours, it would take days to test everything to ensure implementing an application wide URL Rewrite wouldn't cause any problems elsewhere.
But, since every domain sets a different set of variables, I was able to find a simple solution.
I feed every domain into the same default document, i.e. RerouterPage.aspx that then looks at the domain of the request, compares it to my database to determine the portal ID (the ?e=##) of the request and then set all the variables accordingly. Afterwards it redirects the user to the correct landing page.
Here's a little sample of what my code looked like for the RerouterPage.aspx

I got into kind of a stupid habit left over from when I used to develop in PHP, but when I make an images folder, I usually divide my images up into several different subfolders related to their purpose and for all general images, I just toss them into a subfolder named "bin". You can probably guess where this is going. IIS7 blocks view access to all folders in your solution named bin. Unfortunately, the images/bin/ folder is referenced throughout the entire site and would be a monsterous task to go through and replace.
Luckily, through some research I found this work around that seems to work great:
Now the bin subfolder within the images folder has view access.
Default Documents can not include Query Strings

The Issue
On our older server, we had many domains feeding into the same web application, yet each domain would set certain variables through the query strings of the default document of the site.
For instance, a domain "myExample.com" a default page "DefaultPage.aspx?e=29" would set all the variables necessary for portal #29.
With IIS7, we no longer have this luxury, and must only feed in a single filename, i.e. "DefaultPage.aspx"
Issues for Multiple Websites with the Same Home Directory
One of my first thoughts was, ugh, am I really going to have to create a seperate landing page for EVERY domain linking into the site? As you'll read in the work-around, no. That's not the best way to do it. And as it turns out, it's not even possible. For every Home Directory you route to in IIS7, you have to use the same landing page for all websites pointing to that folder. So, if I have myExampleA.com and myExampleB.com both pointing to c:\inetpub\wwwroot\myExamples\ and I define myExampleA.com's default document to be WelcomeToA.aspx, then myExampleB.com will inherit the same default document. They have to be the same. Another big change for default documents when migrating from IIS6 to IIS7.
The Solution
I've noted several people using URL Rewrites to solve this, but with an application as large as ours, it would take days to test everything to ensure implementing an application wide URL Rewrite wouldn't cause any problems elsewhere.
But, since every domain sets a different set of variables, I was able to find a simple solution.
I feed every domain into the same default document, i.e. RerouterPage.aspx that then looks at the domain of the request, compares it to my database to determine the portal ID (the ?e=##) of the request and then set all the variables accordingly. Afterwards it redirects the user to the correct landing page.
Here's a little sample of what my code looked like for the RerouterPage.aspx
Public Sub Form_Load() Handles Me.Load
If Session("portal") Is Nothing Then
If Request("e") = "" Then
Session("portal") = PullPortalBasedOnDomain()
Else
If IsNumeric(Request("e")) Then
Session("portal") = New Portal(Request("e"))
Else
Response.Redirect("~/NoPortal.aspx")
End If
End If
End If
If CType(Session("portal"), Portal).PortalID = 0 Then
Response.Redirect("~/NoPortal.aspx")
End If
Response.Redirect("~/" & CType(Session("portal"), Portal).LandingPage)
End Sub
Private Function PullPortalBasedOnDomain() As Portal
Dim thisDomain As String = "http://" & Request.ServerVariables("SERVER_NAME").ToString
thisDomain = thisDomain.Replace("www.", "")
Return Portal.GetPortalBasedOnDomain(thisDomain)
End Function
IIS7 Blocks Images in Bin Folders

The Issue
I got into kind of a stupid habit left over from when I used to develop in PHP, but when I make an images folder, I usually divide my images up into several different subfolders related to their purpose and for all general images, I just toss them into a subfolder named "bin". You can probably guess where this is going. IIS7 blocks view access to all folders in your solution named bin. Unfortunately, the images/bin/ folder is referenced throughout the entire site and would be a monsterous task to go through and replace.
The Solution
Luckily, through some research I found this work around that seems to work great:
</system.webServer>
<location path="images/bin">
<system.webServer>
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin" />
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
</location>
Now the bin subfolder within the images folder has view access.
Labels:
asp.net,
bin,
default document,
filename,
home directory,
iis6,
iis7,
images,
landing page,
migrating,
query strings,
solution,
upgrading,
vb.net,
web.config
Tuesday, February 1, 2011
How to sort a YouTube Query with the .NET API SDK
Having trouble sorting the .NET YouTube API video feed?
Countless sites will tell you than in order to sort your videos by the date they were published, all you need to do is set the query.OrderBy property or in some instances the query.setOrderBy property to Google.GData.YouTube.YouTubeQuery.OrderBy.Published.
While working with Intellisense, I noticed that no such values are provided by the OrderBy method. I attempted just using a string query.OrderBy = "Published" but got an error "". Likewise, I thought maybe it's a numerical Enum type and attempted query.OrderBy = 1, but still no luck.
Finally after doing a bit of trial and error, I got it to work with the string "published" (all lowercase).
query.OrderBy = "published"
You can order your videos by a couple different fields, but the string must match these options case sensitvely:
relevance
published
rating
viewCount
Notice: viewCount has an uppercase C
Countless sites will tell you than in order to sort your videos by the date they were published, all you need to do is set the query.OrderBy property or in some instances the query.setOrderBy property to Google.GData.YouTube.YouTubeQuery.OrderBy.Published.
While working with Intellisense, I noticed that no such values are provided by the OrderBy method. I attempted just using a string query.OrderBy = "Published" but got an error "". Likewise, I thought maybe it's a numerical Enum type and attempted query.OrderBy = 1, but still no luck.
Finally after doing a bit of trial and error, I got it to work with the string "published" (all lowercase).
query.OrderBy = "published"
You can order your videos by a couple different fields, but the string must match these options case sensitvely:
relevance
published
rating
viewCount
Notice: viewCount has an uppercase C
Tuesday, January 25, 2011
Getting your .NET 4.0 site to work with II6
Having trouble getting your ASP.NET 4.0 site to work while using IIS 6?
I recently encountered the same problem, but was able to get it working by enabling the dll for the .NET 4 ASP.NET ISAPI extension.
Johan Driessen has put together a great tutorial on how to do this:
http://johan.driessen.se/archive/2010/04/13/getting-an-asp.net-4-application-to-work-on-iis6.aspx
I recently encountered the same problem, but was able to get it working by enabling the dll for the .NET 4 ASP.NET ISAPI extension.
Johan Driessen has put together a great tutorial on how to do this:
http://johan.driessen.se/archive/2010/04/13/getting-an-asp.net-4-application-to-work-on-iis6.aspx
Thursday, January 20, 2011
Reference Removed Build Visual Studio 2010
Having trouble with a reference you imported when you try to build or debug an application with Visual Studio 2010?
I noticed an issue with VS2010 when I was creating a simple VB.NET console application using Google's GData Client API. I began by adding the reference to a .dll file and then adding a "Imports Google.GData.Client" to the top of my code. All pretty standard right?
I was then able to write out the code for my application using this API; everything seemed to be working fine. Intellisense picked up the classes and all. Then I tried to debug and everything fell apart.
Suddenly it was if I had never added the reference to my class. I was getting Type not defined errors and namespace issues with my imports statement. I checked my references and found my expected .dlls, but went ahead and re-added them anyways. All my errors cleared out and everything again looked fine. I tried to build and debug again and kept hitting the same issue.
After a long time, I finally found a solution!
Go to your application's properties, click on the Compile tab and set the "Target framework (all configurations):" dropdown from ".NET Framework 4 Client Profile" to ".NET Framework 4"

Click OK and save. Your applications will probably shut down all windows, but now you should be able to debug and build your application successfully (assuming you have no other errors). At least the reference issue will be solved.
I noticed an issue with VS2010 when I was creating a simple VB.NET console application using Google's GData Client API. I began by adding the reference to a .dll file and then adding a "Imports Google.GData.Client" to the top of my code. All pretty standard right?
I was then able to write out the code for my application using this API; everything seemed to be working fine. Intellisense picked up the classes and all. Then I tried to debug and everything fell apart.
Suddenly it was if I had never added the reference to my class. I was getting Type not defined errors and namespace issues with my imports statement. I checked my references and found my expected .dlls, but went ahead and re-added them anyways. All my errors cleared out and everything again looked fine. I tried to build and debug again and kept hitting the same issue.
After a long time, I finally found a solution!
Go to your application's properties, click on the Compile tab and set the "Target framework (all configurations):" dropdown from ".NET Framework 4 Client Profile" to ".NET Framework 4"

Click OK and save. Your applications will probably shut down all windows, but now you should be able to debug and build your application successfully (assuming you have no other errors). At least the reference issue will be solved.
Labels:
console,
framework,
import,
property,
reference,
target framework,
vb.net,
Visual Studio 2010