Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to convert Sharepoint Console Applications to Web Applicationss or ASP .Net pages

Posted on 2010-08-17
5
Medium Priority
?
438 Views
Last Modified: 2012-06-27
Environment = WSS 3.0 sp2, Windows 2003 sp2, Visual Studio 2008.

I have 5 scripts that I've written in Visual Studio 2008 as console applications that I want to convert or port to a version that can be loaded in an .aspx page.

Right now the console applications basically are reading list information in various ways and exporting to CSV format, through scheduled tasks in windows.  I would like to have pages that could be called/loaded and do this process and deliver the CSV file to them.

Does anyone have a quick way to convert these to web pages .aspx files or perhaps some web resources that can point me in the right direction?  Do I have to write a web service (sounds complicated and my first forays into that were time consuming)...  any help would be appreciated
0
Comment
Question by:rmicone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
Hairbrush earned 2000 total points
ID: 33462809
The simplest way I know of is as follows:

In Windows Explorer, navigate to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS and under this create a new folder such as "tools".  In this folder, you can place ASPX pages.

The pages that you create in this folder can then be accessed from any web, as follows:

http://<servername>/_layouts/tools/mytool.aspx

You might not need all the imports in the following code sample, but it will give you an idea how to structure your page.

I have not addressed the security issues in doing it this way... that's up to you!!

Hope this helps.
<%@ Page Language="C#" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Import Namespace="Microsoft.SharePoint.Utilities" %>
<%@ Import Namespace="Microsoft.SharePoint.WebPartPages" %>
<%@ Register Tagprefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>




<script runat="server">
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
    }

    protected void btnApply_Click(object sender, EventArgs e)
    {
        using (SPSite site = new SPSite(SPContext.Current.Site.ID))
        {
                // your code goes here
                
                Response.Write("success<br/>");
            }
        }
    }



</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="btnApply" runat="server" OnClick="btnApply_Click" Text="Apply" />
    </div>
    </form>
</body>
</html>

Open in new window

0
 
LVL 2

Author Comment

by:rmicone
ID: 33503840
great thanks, are you using VS2008? or SP Designer 2007?  I can't get this to load, it's a good example of what I want to do, but I can't get it to load.  I just keep getting "Unknown Error" when the page loads.
0
 
LVL 12

Expert Comment

by:Hairbrush
ID: 33503887
You should be able to use VS or SPD.

Can you check your SharePoint logs in case there's anything to suggest what the problem is?
0
 
LVL 2

Author Comment

by:rmicone
ID: 33504328
I'm getting :
08/23/2010 12:04:14.74       w3wp.exe (0x0550)                             0x01F0      Windows SharePoint Services         General                             8dzz      High          Exception Type: System.Web.HttpCompileException  Exception Message: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\9ef2dd1b\e1b1f8b\App_Web_tooltest2.aspx.a108871c.vttdyx_y.0.cs(154): error CS1518: Expected class, delegate, enum, interface, or struct

my code is below, i tried your code, same error, so I'm just using the default code that is included when you create a new .aspx page in vs2008 for the html

thanks for your help, let me know


<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Import Namespace="Microsoft.SharePoint.Utilities" %>
<%@ Import Namespace="Microsoft.SharePoint.WebPartPages" %>
<%@ Register Tagprefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<script runat="server">
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
    }

    protected void btnApply_Click(object sender, EventArgs e)
    {
        using (SPSite site = new SPSite(SPContext.Current.Site.ID))
        {
                // your code goes here
                
                Response.Write("success<br/>");
            }
        }
    }

</script>


<html dir="ltr">

<head runat="server">
<META name="WebPartPageExpansion" content="full">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled 1</title>
</head>

<body>

<form id="form1" runat="server">
</form>

</body>

</html>

Open in new window

0
 
LVL 2

Author Comment

by:rmicone
ID: 33505477
ok i got it, there was a extra } in there, this works, thank you for the help!  corrected code attached
<%@ Page Language="C#" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="Microsoft.SharePoint.Utilities" %>
<%@ Import Namespace="Microsoft.SharePoint.WebPartPages" %>
<%@ Register Tagprefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<script runat="server">
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
    }

    protected void btnApply_Click(object sender, EventArgs e)
    {
        using (SPSite site = new SPSite(SPContext.Current.Site.ID))
        {
                // your code goes here
                
                Response.Write("success<br/>");
            
        }
    }



</script>


<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
	<asp:Button ID="btnApply" runat="server" OnClick="btnApply_Click" Text="Apply" />
        test1
    </div>
    </form>
</body>
</html>

Open in new window

0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question