Posted by Ajay Matharu in .Net, ASP.Net, Visual StudioOct 9th, 2009 | No Comments
The .Net Framework has a feature called Shadow Copy.
Shadow copy is enabled on every appdomain created by ASP.NET by default. By default assemblies loaded will be copied to a shadow copy cache directory, and will be used from that location.
But this may create problem sometimes.
Posted by Ajay Matharu in .Net, ASP.Net, Development, Visual StudioSep 7th, 2009 | No Comments
The following code snippet will help you to catch an error in the global.asax file,
Turn off the custom error mode in web.config file first,
<customErrors mode="Off">
And add this code in your global.asax file to catch the error,
void Application_Error(object sender, EventArgs e)
{
HttpContext context = ((HttpApplication)sender).Context;
if (context.Error != null)
{
Exception ex = context.Error;
string msg = string.Empty;
while (ex != null)
{
if (!string.IsNullOrEmpty(ex.Message))
msg += ex.ToString() + "<br /><br />";
ex = ex.InnerException;
}
context.Response.Clear();
...
Posted by Ajay Matharu in .Net, ASP.Net, Development, Visual StudioAug 28th, 2009 | No Comments
I have been getting good response for my post Integrating blog engine into existing site. One of the guy asked me this question on how can we do the opposite? He had a BlogEngine as parent site and needed some other site to be child of BlogEngine. So He posted on that and this is the answer he got for his question.
You need to make this change in your web.config file. If you want to have a website as child of BlogEngine
<location path="." inheritInChildApplications="false">
<system.web>
..... existing content .....
</system.web>
</location>
<location path="." inheritInChildApplications="false">
...
Posted by Ajay Matharu in .Net, ASP.Net, DevelopmentJul 26th, 2009 | No Comments
Many a time while developing a web application you may come accross “Server application unavailable”
When you get this error in Windows XP make sure you have given ASPNET user sufficient rights on your physical application folder, it mainly requires read permission.
When you get this error in Windows 2003 server you can right click your virtual directory – permission – grant aspnet user sufficient rights there.
Posted by Ajay Matharu in .Net, ASP.Net, Development, Sharepoint, Technical, TechnologyJul 25th, 2009 | No Comments
Here is the way we can add item level permission for a user on an item,
SPRoleDefinition oUserRole;
SPRoleAssignment oUserRoleAssignment;
SPListItem itm;
SPSite site = null;
SPWeb web = null;
string siteUrl = Request.Url.ToString();
site = new SPSite(siteUrl);
web = site.OpenWeb();
SPGroup grp = web.Groups[groupname];
itm=web.Lists["Shared Documents"].Items[0];
oUserRole = web.RoleDefinitions.GetByType(SPRoleType.Administrator);
oUserRoleAssignment = new SPRoleAssignment(loginName, emailId, userDisplayName, notes);//for user
or
oUserRoleAssignment = new SPRoleAssignment(grp);//for group
oUserRoleAssignment.RoleDefinitionBindings.Add(oUserRole);
itm.RoleAssignments.Add(oUserRoleAssignment);
web.AllowUnsafeUpdates...