Thursday, December 29, 2011

GoDaddy - Using host entries to access your site by IP

Problem

Your site is live right now and you want to transfer it to another account hosted in GoDaddy.com. You have configured the site in new account and want to test it, but you can not directly update the DNS records without testing. You don't want to purchase a static IP for this. So, there should be a way to test your site before updating DNS records.

Solution

One of the solution is the use hosts entries. That will help you to access your domain point to the new IP only for you. That way, when other people accesses www.yoursite.com, it will be served from original site, but because of the host entry, when you try to access www.yoursite.com it will be served from the new server. I found the detailed instruction here: http://help.godaddy.com/article/3354

Friday, December 23, 2011

Runtime error: ; expected


I was working in asp.net with vb.net for for almost 3 years now, and now after 3 years, just started working on c# as back end language. So many times in a day I miss writing ; and got the this error!

I recently got this error in ascx control as well, when I was working in a repeater item template and missed # and write Eval like <% Eval...

Compiling code in C# reminds me to the starting of my career since I have worked on C# first.

Friday, December 16, 2011

Sharepoint: Debugging - which process to attach

As some of you may already be knowing, I have just joined a team of sharepoint developers and right now learning sharepoint development.



This is my first day to work on a development after watching videos and reading books and I already find myself lost while attaching to the process for debugging a webpart control in sharepoint. Here is how I finally got my ProcessID to attach:

Just open command prompt as administrator and type following:

%windir%\system32\inetsrv\appcmd.exe list wp

Hope this will help to the developers who are new OR not knowing the way to find which process to attach.

Happy coding.

Sunday, April 10, 2011

OSDNNSKINS: New version of cash and multiflex with portal template available

Hi all,

New Version for Cash and Multiflex is available for download. This time we have three common changes for both of the skin packages.
  1. There is only single package for skin and container installation
  2. Portal template is available to quickly evaluate the skin. 
  3. Both of the skins are tested in dnn 6.0.0.44 
For those who are not knowing about this, open source dotnetnuke skins is an initiative to provide high quality free skins to dnn community.

More contributors to osdnnskins:

We have more contributors to join the party, so we welcome issues and suggestions from community in order to help them provide quality skins for free.

there are lots of evaluations and  also there are many sites using skins from osdnnskins, there are very less number of comments and feedback that we get.


Please please please provide your feedback about any skin that you evaluate and you can directly go to osdnnskins.codeplex.com to create a new issue or you can email me any time for any kind of help regading the same.
You can contact email @ lakhlaniprashant [at} gmail [dot} com

Thursday, April 7, 2011

Database Design : Smartly storing many user settings with Boolean values in a single value

It is obvious that when we design database tables for storing user preferences we look user settings as one-to-many relationship, but there are cases when all your setting values are boolean. For example, you have many type of newsletters (infoq.com has .net, java, soa etc) and you want to user choices, OR you have many categories of articles and you want to store which categories user is interested to browse, user choose tags (fev tags)  are also good example in stackoverflow.com.

Problem:
How to efficiently store user preferences which are all having boolean values.

Classic solution:
  • Create a subscription_type database which stores all the subscription types
  • Create a user_subscription table user_subscriptions with columns user_id and subscription_id
  • Insert a new row for each kind of subscription for each user
  • Delete a row for each kind of subscription user un-check (In case user checks the subscription and un-checks it after some days)
This will work fine but the only problem is to maintain an extra table for storing the details.

Better Solution:
  • Create a subscription_type table which stores all the subscription types.
  • add a new column in users table for subscription.
  • use following query to retried user subscriptions:
    select
            user_id,
            case when
                subscription & power(2,subscription_type_id) =0
            then 0
            else 1 end as is_subscribed,
            subscription_type_id,
            subscription_type_name
        from users cross join subscription_types
        where user_id = @user_id
  • user following query to store user subscription:
    select sum( power(2,subscription_type_id)) from subscription_types where subscription_type_id in (1,2,3)
here subscription_type_id in (1,2,3) describes the subscription type id user is subscribed to.

How It Works:
We are storing sum of binary power as user preference. For example, user is subscribed to subscription type 0,1, and 3 we are storing power(2,0) + power(2,1) + power(2,3) = 1 + 2 + 8 = 11.
For reading a boolean value of subscription we are using t-sql’s AND (&) operator. We are doing and operation of 11 and binary power of subscription type, and it we get 0 means user is not subscribed, otherwise we will get power(2,subscription_type) as result of AND operation.

Conclusion:
We can say the solution is better because you can using single query to read and write the subscription. It is more faster, and requires no additional table. There are many other advantages that you can think of.

Limitations:
Every time you take this kind of solution, you are killing possibility to store details that depends on the relationships. In our subscription example, you will never get information about when does a user subscribed to which subscription type individually.
If that is not important to you, you can obviously go for it.

Note:
Please note that in actually situations, subscription table and related designs are really more complicated than what I’ve shown above, so it demonstrates the example scenario and not the example database design for any kind of system.
Have fun with your database design!

Saturday, December 11, 2010

Using master pages and aspx pages in dnn

In this post, we are going to see how we can add new aspx pages by re-using the existing skin designs to implement some helpfull programming in it.


Why?


If you are running a multi-portal dnn website and want to build some common pages to share between those portals, there are couple of quick ways to do that.

  1. 1. Create a new tab in portal 0 and then share link in all other portals.
    This technique works fine when you want to show "how to" page or help page, static contents or offers related pages. You don't need any custom coding for this and it will be a matter of adding a text html module and paste the html that you designed!
  2. 2. Create a new aspx page and share link in all other portals.
    Well, this one also looks similar to first option but let's think about this: If you are running a multi-portal dnn site and want to show latest offers from all the portals into a page based on user's country, and users having at least 5 orders in history. Now, this will involve some quick coding to do. So, basically, if you want to show content based on some dynamic parameters like user or portal data or similar data, it will be good to create an aspx page.
There is another option! obviously you can create a new module to do this, but remember that we are not doing anything that depends on moduleId or tabId but depends on UserId or PortalId, so I believe it's a quick way to create a new page in place of building an entire dnn module.

How?

  1. 1. Create a new theme
    Create a new theme with the name of your skin and paste your skin's css and images into it.
  2. 2. Create a new master page
    Create a new master page and paste your skin's ascx control's entire markup over there. Replace all your content pane (i.e. div or tds with runat=server) with CotentPlace holder
  3. 3. Create a new page
    - Add a new aspx page called Default2.aspx and select the new master page when creating it. 
    - Go to .aspx.vb file and make your parial page class inherit from DotNetNuke.Framework.PageBase in place of System.Web.UI.Page 
    - And that's it you are ready to go!

Conclusion

It is really easy to add a new aspx page in dnn that is re-using skin and you will be able to access all the information like PortalSettings, UserInfo etc. Things like Tab and Module will not be there and it's obvious!
This post doesn't say you should create a new aspx page in some cases or not, but demonstrates how to do it if you want. If you have some good examples WHEN we can use it or some good examples WHEN we should NOT use it, I welcome them! 
This example will probably work with dnn 4.x and 5.x, though I've used this in dnn 4.5.6 and 5.2.0 etc.

Downloads

You can download the example code for this example from codeplex Happy coding with dnn

Saturday, December 4, 2010

DotNetNuke 5.6 - A potentially dangerous Request.Form value was detected from the client

Today morning, when I was preparing for a new installation instance for dnn 5.6, I was facing trouble to install new module, create new tab and I come to the conclusion that any post back event from the site was causing the "potentially dangerous Request.Form value".

I was still able to install module using /Install/Install.aspx?mode=installresource but finally stuck when I was not able to add the installed module into page.

Finally, after reading several articles on web, I found web.config's httpRuntime element needs another attribute called : requestValidationMode="2.0"

I go the solution here (
http://stackoverflow.com/questions/81991/a-potentially-dangerous-request-form-value-was-detected-from-the-client/3368769#3368769).

And finally, I was on my way to regular work.
please note that I was trying this on having webmatrix installed and I was browsing the site in asp.net 4.0 integrated mode.
Hope this will help to someone in the same kind of trouble.

Popular Posts