Tag Info

Hot answers tagged

8

It sounds like you are reinventing the wheel. SharePoint ships with an Auditing infrastructure, which although flawed, will probably give you what you need. Have a look at the following: When using WSS3 or SharePoint Foundation you don't get a user interface so you will need to set and query it programmatically. (2007 article, but it works the same in ...


4

Indeed, that should be all you need to do to get the module to work. I would wrap this up though in a solution that deploys the DLL to the GAC, and a Farm-scoped Feature with Receiver Code that injects the required lines into web.config using SPWebConfigModification. You could do it manually, but if you have multiple web front ends, this method will ...


4

You could enable audit on the 'View' events of the SPListItem. You can then query with something like: SPSite site = ... SPListItem item = ... SPAuditQuery query = new SPAuditQuery(site); query.RestrictToListItem(item); SPAuditEventType[] eventTypes = new SPAuditEventType[] { SPAuditEventType.View }; SPAuditEntryCollection auditLog = ...


3

You may want to consider an alternative to the blog poist your referenced that does not require a custom HTTP module. SharePoint 2010 allows you to register your own custom error page without the need for a custom HTTP module. http://todd-carter.com/post/2010/04/07/An-Expected-Error-Has-Occurred.aspx


3

I have encountered the exact same issue you're having - a HTTP Module that handles 404, and getting 404's (and thus an infinite loop or a 500) when going to Manage Content and Structure. We also did what you did, and just remove the module for the authoring environment, but another 'short term' workaround until Microsoft sort this, is to put a 1x PNG file ...


3

Is SPContext.Current not yet available at this time? You should be able to get it from this. (SPContext.Current.Site.WebApplication from the top of my head) Be careful though as this will call into the SharePoint object model for each incoming request, which will most likely hit the database as well. This may wreak havoc on performance and scalability.


2

Firstly, no normal user can run the code in their identity to open any SPSite or SPWeb; The code is running under the application pool account and that's the reason that "web.CurrentUser" is always dev_admin . Always use "SPContext.Current.Web.CurrentUser.LoginName". Also, it's strange the "HttpContext.Current.User.Identity.Name" is also giving you the ...


2

Is this really important? LCID should be handled by the user profile itself (user language). Per design page views are not tracked (audit) and the argument here are again performance. Even if you threw in a webcontrol that monitored usage, your caching strategy would be limited. You could consider setting some of the values in a cookie, or doing the check ...


2

Not a good idea to use a handler for this. This code would run every time a page is called. Instead use the WebProvisioned event to set the theme when a site is created. @toni-frankola has an example on how to do this here. public override void WebProvisioned(SPWebEventProperties properties) { ThmxTheme theme = ...


2

The problem is that I was trying to do the following inside the handler: SPSite siteColl = SPContext.Current.Site; var webs = siteColl.AllWebs; And that fails when a non-admin user is logged in. So instead of using AllWebs, I used: var webs = siteColl.OpenWeb().GetSubwebsForCurrentUser() More info about GetSubwebsForCurrentUser() here


2

Common issue is: The web part is located on a page of subsite, and tries to retrieve data from '/_layouts/somefolder/somehandler.ashx'. But this url is the url of root site which user have not access to. In this case you should use '<%= SPContext.Current.Web.ServerRelativeUrl %>/_layouts/somefolder/somehandler.ashx' $.ajax({ url: "<%= ...


2

1) register the HttpModule in the web.config for the Web application where you need it, in your case, C:\inetpub\wwwroot\wss\VirtualDirectories\80\web.config, use this page as a guide to how to register you HttpModule 2) You should sign the dll and deploy it to the GAC 3) You should really do this as Web Application scoped feature deployed in a WSP a using ...


2

If it doesn't work as expected then I would recommend you to use Xpath together with SPWebModifications to define the order. Update I just tested it out my solution together with XPath solution and it's not behaving as expected. It seems that there is no way of controlling the order of entries. Thanks Per for his input! Update 2 Could you please try ...


2

The default value is null which sililar to empty string or wrong filename gives the default handling. If having the same error page for the entire web app is OK, then I'd recommend setting SPWebApplication.FileNotFoundPage instead of using a HttpModule. Remember that the filename is relative to {SharePointRoot}\TEMPLATE\LAYOUTS{LCID} and the file should ...


2

Yes, the nodes are being alphabetically sorted and the Sequence property only applies when the Name property is exactly the same. To fix, use a little XPath trickery to get your nodes to sort in the correct order (first modules[1=1] then modules[2=2]): SPSecurity.RunWithElevatedPrivileges(delegate { SPWebService spWebService = ...


2

In IIS8 (which you are using, if you are using SharePoint 2013) it uses ASP.NET 4.5. The application events are different from 3.5 and are raised in the following order: BeginRequest AuthenticateRequest PostAuthenticateRequest AuthorizeRequest PostAuthorizeRequest ResolveRequestCache PostResolveRequestCache After the PostResolveRequestCache event ...


2

As mentioned in the blog post you references, it simply needs to happen after the response has been created (i.e. the page content) and before the UpdateRequestCache event. The blog post shows an idea example of using the PostRequestReleaseState event. This happens almost immediately after the response is generated. public void Init(HttpApplication app) ...


1

The SPHttpApplication class is declared in the Global.asax file at the root of the virtual directory for the SharePoint Foundation application. Normally, SPHttpApplication objects are not created with application code. The first time a SharePoint Foundation page is requested, a SPHttpApplication object is automatically created by Microsoft ASP.NET through ...


1

You're best handling this in a custom control on the masterpage - HTTPModules will fire on every single request, and potentially kill performance if you're not careful.


1

This is the natural behaviour of HttpContext When you try to redirect the page, the current thread will be aborted and the system will throw an exception. If you don't want the thread to abort, pass false to redirect method. response.Redirect(message, false);


1

You can try to use somwthing like this public void Init(HttpApplication application) { application.BeginRequest += (new EventHandler(this.Application_BeginRequest)); application.EndRequest += (new EventHandler(this.Application_EndRequest)); } // Your BeginRequest event handler. private void Application_BeginRequest(Object ...


1

You need to register the script. Something like : if(!ClientScript.IsClientScriptIncludeRegistered("ScriptFile")) { ClientScript.RegisterClientScriptInclude("ScriptFile", "/UserControls.js"); } Here is reference!


1

Is seems as if the module hasn't been added correctly to the web.config for the alternate zone. Have you compared the web.config for the two zones?


1

No. An HttpModule is added to the HTTP pipeline for requests/responses for a particular web application, so it's a broader scope. You could have a dedicated web application for a single site collection. Or you could check within the HttpModule that the site collection is one you want to process (I would consider storing some sort of flag in the ...


1

1) C:\inetpub\wwwroot\wss\VirtualDirectories\80\web.config 2) C:\inetpub\wwwroot\wss\VirtualDirectories\80\bin But it is considered better to sign the assembly and put it in GAC.


1

When you tries to save data to DB on GET request, SharePoint trims this operation by security reason. To solve this problem you can use AllowUnsafeUpdates property of SPWeb. bool unsafeUpdates = SPContext.Current.Web.AllowUnsafeUpdates; try { SPContext.Current.Web.AllowUnsafeUpdates = true; // your code } finally { ...


1

Long story short - you don't. The CallStack attribute specifically hides this information, to prevent users from getting the very information you are trying to get. The point of the "Callstack = false" being best practices is because if this is set to "True", too much information is exposed to users - if you are intercepting this process and injecting your ...


1

You have to take into account that every request (including images / simple files on the server's file system) goes through the HTTP Module, so any time you spend in the SharePoint object model will most likely include at least 1 database call, which will reduce the scalability of your solution significantly. Our URL Shortener for SharePoint uses an HTTP ...


1

public void Init(HttpApplication application) { //This is the first event that has SPContext populated for use application.PreRequestHandlerExecute += new EventHandler(application_PreRequestHandlerExecute); } Then in the application_PreRequestHandlerExceute you can access SPContext.Current.



Only top voted, non community-wiki answers of a minimum length are eligible