Your application will be embedded into SharePoint Asp.NET book review
|
Get your FREE Diabetes Recipes eBook! |
Why should Asp.net application embedded into SharePoint? We do not discuss this! We will be discussing is how the application will be embedded in Asp.net SharePoint, and which may be encountered.
Text start:
Here is to create a Web application which has a Demo.aspx page, the code is as follows:
namespace WebInMOSS
{
public partial class _Demo: System.Web.UI.Page
{
protected void Page_Load (object sender, EventArgs e)
{
Response.Write (“Web Can In Moss”);
}
}
}
Compile this program to generate a WebInMOSS.dll file copy this dll to the bin folder under the web directory, add nodes:
And then into the MOSS in Demo.aspx page. Into the way you can choose to use the SPD, or simply upload a document library. Us into the “Pages” in.
In MOSS browse pages / Demo.aspx,
Whether to delete autoeventwireup can it? Indeed, deletion AutoEventWireup = “true” after the
Page displays the Web Can In Moss, proof of successful execution.
Increase the complexity of web applications, in Demo.aspx into a button, its event as follows:
protected void Button3_Click (object sender, EventArgs e)
{
SPSite siteCollection = new SPSite (“http://xuwei:8080/”);
SPWeb site = siteCollection.OpenWeb (“/ Docs /”);
SPList list = site.Lists ["notice"];
SPListItemCollection items = list.Items;
foreach (SPListItem item in items)
{
Response.Write (“
“);
Response.Write (item ["Title"]. ToString ());
}
}
Debugging in VS2005 the outcome (please ignore the write session you spectators and read session 2 个 button):
The program will be re-compiled dll, Demo.aspx in by the front way into the MOSS. Browse again
At this point the incident can not be used Onclick appeared, what to do? We must start the MOSS security model can be implemented server-side events. Operation is as follows:
We find the Web.config file
Node to add a virtual path
Statement This site allows all the files under the server-side event, of course, you can develop a virtual directory is the folder, but this value must be ~ / or / at the beginning, and the file name or * must end.
Save Demo.aspx and view the page, to display properly, click listobject button (please ignore the write session you spectators and read session 2 个 button), OK, normal execution shows!
Further increase the complexity of web applications, add Session, (in the MOSS development to take that way regardless, as long as the procedures and their integration, there will always encounter Session of the problem).
Code:
protected void Button1_Click (object sender, EventArgs e)
{
Session ["Count"] = “1″;
}
protected void Button2_Click (object sender, EventArgs e)
{
if (Session ["Count"]! = null)
{
Response.Write (“
” Session ["Count"]. ToString () “ font>“);
}
}
Save compilation browser page again, click listobject button to display the results correctly, but when you click Write Session occurs when
This prompted domineering enough! Who knows what unexpected error! I tried to modify the
Find out what trail, but fortunately, is expected to start Session may be problems, check the Web.config found
Oh, Session default is turned off, of course, not run properly. Set it to true and save. View demo.aspx page, click write session and read Session, the normal execution.
Some important issues can finally solved! If we encounter other problems, we continue the discussion!
Sorry, the comment form is closed at this time.


Comments
No comments yet.