iis - How do you take a C# script and make it output a html page? -


i code in php , python, in case have make in c#.

i have code, works good. console application.

but how can make c# .net can put on iis?

basicly instead of outputting console, should write browser.

i have tried search c# web, not find anything.

thanks help!

using system; using system.net; using independentsoft.exchange;  namespace sample {     class program     {         static void main(string[] args)         {             networkcredential credential = new networkcredential("username", "password");             service service = new service("https://myserver/ews/exchange.asmx", credential);              try             {                 isgreaterthanorequalto restriction1 = new isgreaterthanorequalto(appointmentpropertypath.starttime, datetime.today);                 islessthanorequalto restriction2 = new islessthanorequalto(appointmentpropertypath.endtime, datetime.today.adddays(1));                 , restriction3 = new and(restriction1, restriction2);                  finditemresponse response = service.finditem(standardfolder.calendar, appointmentpropertypath.allpropertypaths, restriction3);                  (int = 0; < response.items.count; i++)                 {                     if (response.items[i] appointment)                     {                         appointment appointment = (appointment)response.items[i];                          console.writeline("subject = " + appointment.subject);                         console.writeline("starttime = " + appointment.starttime);                         console.writeline("endtime = " + appointment.endtime);                         console.writeline("body preview = " + appointment.bodyplaintext);                         console.writeline("----------------------------------------------------------------");                     }                 }                  console.read();             }             catch (servicerequestexception ex)             {                 console.writeline("error: " + ex.message);                 console.writeline("error: " + ex.xmlmessage);                 console.read();             }             catch (webexception ex)             {                 console.writeline("error: " + ex.message);                 console.read();             }         }     } } 

edit: have tried make asp.net page not print screen.

<%@ page language="c#" autoeventwireup="true" codebehind="default.aspx.cs" inherits="plan.nbt.final.default" %>  <%@ import namespace="system" %> <%@ import namespace="system.net" %> <%@ import namespace="independentsoft.exchange" %>  <%     networkcredential credential = new networkcredential("tedy", "123456889");     service service = new service("https://area51.com/ews/exchange.asmx", credential);      try     {         isgreaterthanorequalto restriction1 = new isgreaterthanorequalto(appointmentpropertypath.starttime, datetime.today);         islessthanorequalto restriction2 = new islessthanorequalto(appointmentpropertypath.endtime, datetime.today.adddays(1));         , restriction3 = new and(restriction1, restriction2);          finditemresponse response = service.finditem(standardfolder.calendar, appointmentpropertypath.allpropertypaths, restriction3);          (int = 0; < response.items.count; i++)         {             if (response.items[i] appointment)             {                 appointment appointment = (appointment)response.items[i];                  response.write("subject = " + appointment.subject);                 response.write("starttime = " + appointment.starttime);                 response.write("endtime = " + appointment.endtime);                 response.write("body preview = " + appointment.bodyplaintext);                 response.write("----------------------------------------------------------------");             }         }      }        %> 

ok quick , dirty asp.net webpage sample. main becomes pageload. sure code behind pages inherit system.web.ui.page (if using vs2008 or vs2010 taken care of you.

using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols;  namespace sample {     public partial class sample: system.web.ui.page     {         protected void page_load(object sender, eventargs e)         {             networkcredential credential = new networkcredential("username", "password");             service service = new service("https://myserver/ews/exchange.asmx", credential);          try         {             isgreaterthanorequalto restriction1 = new isgreaterthanorequalto(appointmentpropertypath.starttime, datetime.today);             islessthanorequalto restriction2 = new islessthanorequalto(appointmentpropertypath.endtime, datetime.today.adddays(1));             , restriction3 = new and(restriction1, restriction2);              finditemresponse response = service.finditem(standardfolder.calendar, appointmentpropertypath.allpropertypaths, restriction3);              (int = 0; < response.items.count; i++)             {                 if (response.items[i] appointment)                 {                     appointment appointment = (appointment)response.items[i];                      lblsubject.text = "subject = " + appointment.subject;                     lblstarttime.text = "starttime = " + appointment.starttime;                     lblendtime.text = "endtime = " + appointment.endtime;                     lblbodypreview.text = "body preview = " + appointment.bodyplaintext;                  }             }           }         catch (servicerequestexception ex)         {             lblerror.text= "error: " + ex.message;             lblxmlerror.text = "error: " + ex.xmlmessage;             console.read();         }         catch (webexception ex)         {             lblweberror.text = "error: " + ex.message;         }     } } 

}

then viewpage this. sure codebehind pointing class code heavy lifting page.

<%@ page language="c#" autoeventwireup="true" codebehind="sample.aspx.cs"     inherits="securecareenrollment.webforms.webform1" %>  <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en"   "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title> </head> <body>     <form id="form1" runat="server">     <div>             <label id="lblsubject" runat="server"></label><br />             <label id="lblstarttime " runat="server"></label><br />             <label id="lblendtime " runat="server"></label><br />             <label id="lblbodypreview" runat="server"></label><br /> ----------------------------------------------------------------<br />             <label id=lblerror" runat="server"></label><br />             <label id=lblxmlerror" runat="server"></label><br />             <label id=lblweberror" runat="server"></label>     </div>     </form> </body> </html> 

obviously there lot more can/should master pages, styling , bunch of other stuff. basic vanilla codebehind , page.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -