Bypass using Alter Access Mappings for to Open Web from SPItemEventProperties
Posted
by Greg Ogle
on Stack Overflow
See other posts from Stack Overflow
or by Greg Ogle
Published on 2010-06-15T18:10:47Z
Indexed on
2010/06/15
20:12 UTC
Read the original article
Hit count: 260
sharepoint
|wss-3.0
In the following code,
// class overrides SPItemEventreceiver
public override void ItemAdding(SPItemEventProperties properties)
{
using (var site = new SPSite(properties.SiteId)) //SiteId is integer
{
...
}
}
The following exception is thrown:
System.IO.FileNotFoundException: The Web application at http://URL could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.
One way to work around this is to hard-code (or configure) the URL specified in Alternate Access Mappings. Putting the correct URL in Alternate Access Mappings is ultimately the correct solution, but if possible, I need a work-around that doesn't require configuration.
© Stack Overflow or respective owner