Yussi Ariefiyono
asp.net
Embedding YAF inside an existing asp.net website
Apr 16th
===The problem===
I have an existing asp.net website with master pages and lots of other stuff. How do I embed yaf into that, so I can use my existing menus and everything, with yaf appearing seamlessly as a page within the site?
If you take yaf "out of the box", then the obvious way to do this is to put the whole thing in an iframe. That kind of works, but there are a few things which don't work too well, and it's kind of complicated and unsatisfactory. In short, it's a hack.
Here's a better way to do this…
===Solution Summary===
Don't use yaf as an application, use it as a control and stick it in one of your site's pages which uses your existing master page(s).
===How to do it===
Here's how to get yaf working without the application thing. This has been tested on iis6 and iss7 with 1.9.1.2.
====prerequisites====
#Install yaf as per the instructions into a subdirectory of your main website. I use ~/yaf.
#Make sure that the standard installation works before you do the following, so you're only dealing with one thing at once.
====step by step====
# Use IIS manager and remove the application you created for YAF in the standard install.
# Move the yafnet.config file from ~/yaf to ~.{br} Ensure that the yafnet.config file "points" to the place where you have YAF installed, in the example case:{br}@@<root>/yaf</root>@@
# Modify ~/web.config.{br}You need to update your main site ~/web.config with most of the contents from the old ~/yaf/web.config. Leave out all the "rewriting stuff" as you're going to switched that off later anyway. Specifically, you seem to need the following. Check carefully where this stuff comes from in the old web.config and make sure you put it in the same sections in your site's web.config. It'll bitch at you if you don't. See additional notes below.:
#*@@<section name="yafnet" type="yaf.SectionHandler,yaf"/>@@
#*@@<yafnet configSource="yafnet.config"/>@@
#*@@<authentication mode="Forms"><forms name=".YAFNET_Authentication" timeout="525600" /></authentication>@@
#*@@<customErrors defaultRedirect="error.aspx" mode="RemoteOnly"/>@@
# Modify ~/yaf/yafnet.config.{br}Disable url rewriting. Set:
#*@@<enableurlrewriting>false</enableurlrewriting>@@
# Delete or rename the old ~/yaf/web.config{br}This will stuff things up if you leave it there on iis6 (you will get an error message at run time of the type "It is an error to [...] allowDefinition='MachineToApplication'").
#Copy or move ~/yaf/yaf.dll to ~/bin/yaf.dll{br}
#Copy or move ~/yaf/framehelper.aspx to ~/{br}
#Create and edit your new yaf forums "container" page.{br}This will reference your own master page and be in your site map etc. You need to add the following lines (you can copy these from the top of the ~/yaf/default.aspx file, which you will not be using):{br}Under the "<%@ Page directive" put
#*@@<%@ Register TagPrefix="yaf" Namespace="yaf" Assembly="yaf" %>@@
#*@@<%@ Register TagPrefix="yc" Namespace="yaf.controls" Assembly="yaf" %>@@
#* In the content place holder where you want to display the forums, put the control tag (you can also copy this from the ~/yaf/default.aspx file):
#*@@<yaf:Forum runat="server" ID="forum" />@@
That's it.
=====Additional Notes=====
#There's a line in the yaf default web.config:{br}@@<xhtmlConformance mode="Legacy"/>@@ If you're using MS Ajax at all on your site and you stick that in the site's web.config, it will break ms Ajax in strange and entertaining ways. [http://weblogs.asp.net/scottgu/archive/2006/12/10/gotcha-don-t-use-xhtmlconformance-mode-legacy-with-asp-net-ajax.aspx|See here] for some background on this. Leave this like out and MS Ajax works again…
Lock User Manually in asp.net membership
Mar 30th
Problem:
Users is automatically locked when he/she entered 3x or more wrong username/passwor ( its depend on what you set in web.config).
Admin need manually lock n unlock Users.
Solution:
unlock is easy, cause its already buildin method for that,
hereby the sample of code:
MembershipUser f = Membership.GetUser(UserID);
f.ChangePassword("OldPasswordHidden", "NewPasswordHidden" );
Membership.UpdateUser(f);
the tricky part is lock the user manually,
with this case, i used tableadapter
Select statement:
SELECT UserId, IsLockedOut FROM aspnet_Membership WHERE (UserId = @UserId)
Update statement:
UPDATE aspnet_Membership SET IsLockedOut = @IsLockedOut WHERE (UserId = @Original_UserId)
And for the code behind, will be:
// create new object
aspnet_MembershipTableAdapter user = new aspnet_MembershipTableAdapter();
//apply Lock method
user.UpdateLock(Convert.ToBoolean("True"), new Guid("userID"));
I hope its usefull.
ASP.NET Routing… how about URL rewriting?
Jan 6th
i have been read couple of new articles about url rewriting and new method for it.
and cross this article, it gives me alot info about it. it really worth to try
these are pics to show what the diffrent of them:
ASP.NET Routing
ASP.NET URL rewriting
source:4guysfromrolla, msdn
Skip complete wizard step in CreateUserWizard
Dec 17th
Problem:
Need to skip last step on CreateUserWizard
Solution:
Add the OnActivate="CompleteWizardStep1_Activate" on last step.
here you can add redirect code, for example:
public void CompleteWizardStep1_Activate(object sender, EventArgs e)
{
Response.Redirect("SomePage.aspx");
}
CreateUserWizard automatically login
Dec 17th
Problem:
after login created, user automatically login.
Solution:
Change the property of “LoginCreatedUser” to False
but if you want to have automatically login change it to true ( default value)