'Programming/ASP.NET'에 해당되는 글 10건

  1. ASP.NET ReportViewer와 Sql Report를 이용한 레포트 작성
  2. IIS와 아파치 동시 사용
  3. 웹 플랫폼
  4. Strongly Typed Dataset의 테이블에 데이터 로드하기
  5. Callback 함수의 예 - GetCallbackEventReference
  6. SOAP Envelope Sample
  7. ThreadAbortException Occurs If You Use Response.End, Response.Redirect, or Server.Transfer
  8. ASP.NET MVC Preview 2
  9. About MVC with VS2008 and ASP.NET
  10. How to make Windows Service with VS2008
ASP.NET ReportViewer와 Sql Report를 이용한 레포트 작성입니다

사전준비) DB는 SQL서버의 AdventureWorks 데이터베이스를 샘플로 이용합니다.

1. 새로은 웹폼을 ReportProduct.aspx이름으로 하여 작성합니다.
2. ReportProduct.aspx에 MicrosoftReportViewer 컨트롤을 올려 놓습니다.

3. 레포트 폼파일을 저장할 폴더로서 Reports를 생성합니다.

4. Reports폴더에 새로운 레포트 폼을 다음과 같이 추가합니다.

5. 새파일 추가를 통하여 데이터셋 파일을 다음과 같이 추가합니다

6. App_Code 라는 폴더가 자동으로 생성되고 dsProducts.xsd파일이 추가된다.

7. dsProducts파일을 오픈하고 TableAdapter를 추가한다.
8. 데이터 커넥션을 연결하는 창이 나오면 AdventureWorks를 선택한다. 이 때 커넥션이 없으면 New Connection을 통하여 새로운 커넥션을 생성해야 한다.

9. 다음을 계속 클릭하여 SQL을 직접 입력화면으로 이동한다. 그리고 아래의 쿼리문을 입력한다. 그리고 Next를 계속 클릭하여 finish한다.

10. 다음의 테이블 어텝터가 생성된다.

11. ReportProducts.rdlc를 오픈하면 좌측 데이터 소스 패널에 Product 테이블을 볼 수 있다.


12. 툴박스에서 테이블 컨트롤을 추가한다.

13. header행의 첫번째 컬럼 부터 'Product Name', 'Product Number', 'List Price'를 입력한다.

14. Detail행의 첫번째 컬럼에는 Name, 두번째 컬럼은 ProductNumber, 그리고 마지막 컬럼에는 ListPrice를 입력한다.

15. Header 행, Details 행, Footer 행을 모두 선택하고 속성에서 BorderStyle을 Solid로 준다


16. ReportProduct.rdlc 파일을 오픈하고 레포트 뷰어 컨트롤의 스마트 태그에서 레포트폼파일을 연결해준다.

17. 레포트 컨트롤의 폭을 800으로 조정한다.

페이지를 로드하면 다음의 화면이 펄쳐진다.

레포트폼을 Sql서버에 저장할 수도 있으나 웹프로젝트에 폼파일을 포함하는 형식을 취했다.

IIS와 아파치 동시 사용

WindowsServer2003-KB892777-SupportTools-x86-ENU.exe 다음의 링크로부터 해당 파일을 다운받는다.

http://www.microsoft.com/Downloads/details.aspx?familyid=6EC50B78-8BE1-4E81-B3BE-4E7AC4F0912D&displaylang=en


httpcfg set iplisten -i 실제IP

위의 명령에 의하여  IIS는 외부에게도 서비스를 제공할  수 있으며 아파티는 localhost(127.0.0.1)만 사용하게 된다

리스닝되는 목록을 보려면
httpcfg query iplisten

리스닝 목록 삭제하려면 httpcfg delete iplisten -i 000.000.000.000

--- 원문 ============

To add an IP address to the IP inclusion list

  1. Click Start, and then click Run.
  2. Type cmd, and then click OK to open a command prompt.
  3. Type the following, where xxx.xxx.x.x is the IP address you want to add:
    httpcfg set iplisten -i xxx.xxx.x.x
    When this succeeds, Httpcfg returns the following:
    HttpSetServiceConfiguration completed with 0

    To view additional status codes, see the Httpcfg help.
  4. After the IP address is added, use the following command to list it:
    httpcfg query iplisten
    Httpcfg returns the following:
    IP :xxx.xxx.x.x
  5. From the command prompt, stop the HTTP service and its dependent services. To do this, type the following string at the command prompt:
    net stop http /y
  6. From the command prompt, restart the HTTP service and it dependent services. To do this, type the following string at the command prompt:
    net start w3svc
    Note When you start w3svc, all services that were stopped when HTTP was stopped will start.

웹 플랫폼

웹 플랫폼 인스톨러 http://www.microsoft.com/web/downloads/platform.aspx

웹 플랫폼 인스톨러는 윈도우 서버에서 사용되는 모든 웹 플랫폼 프레임워크, 웹 어플리케이션, IIS 확장 기능 및 SQL서버와 같은 제품 등에 대한 설치와 구성을 돕는 최고의 툴입니다.

** Strongly Typed Dataset 생성
1. Strongly Typed DataSet을 생성한다.
2. 생성된 DataSet에 DataTable을 추가한다

** 데이터셋에 데이터 로드하기
1. DataSet.DataTable.Load(DataReader)
ex) regCardDS.RegCardQuestions.Load(cmd.ExecuteReader)
      [DataSet].[DataTable].Load(DataReader)


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>WEb Service CallBack</title>
    <script type="text/javascript">
        function GetTemp() {
            var zipcode = document.forms[0].TextBox1.value;
            UseCallback(zipcode, "");
        }

        function GetTempFromServer(TextBox2, context) {
            document.forms[0].TextBox2.value = "Zipcode: " +
            document.forms[0].TextBox1.value + " | Temp: " + TextBox2;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <br />
        <input id="Button1" type="button" value="Get Temp" onclick="GetTemp()" />       
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <br />
        <br />
    </div>
    </form>
</body>
</html>
=====================================================================================
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class SingleParam : System.Web.UI.Page, System.Web.UI.ICallbackEventHandler
{
    private string _callbackResult = null;

    protected void Page_Load(object sender, EventArgs e)
    {
        string cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg", "GetTempFromServer", "context");
        string cbScript = "function UseCallback(arg, context)" + "{" + cbReference + ";" + "}";

        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "UseCallback", cbScript, true);
    }

    public void RaiseCallbackEvent(string eventArg)
    {
        _callbackResult = "zzzzzzzzzzzzzz";
    }

    public string GetCallbackResult()
    {
        return _callbackResult;
    }
}

SOAP Envelope Sample


Client Windows applicaton
------------------------------------------------------------
Public Class frmMain

    Private Sub btnTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest.Click
        TextBox1.Text = String.Empty

        Dim obj As New wsSampleSoap.AuthHeader
        Dim ws As New wsSampleSoap.Service1

        obj.UserName = "admin"
        obj.Password = "dotnet"

        ws.AuthHeaderValue = obj
        TextBox1.Text = ws.GetCustomerList()
    End Sub
End Class
-----------------------------------------------------------

** SOAP Web Service

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;

using System.Web.Services.Protocols;
using System.Xml.Serialization;


namespace SampleSoapMessage
{

    public class AuthHeader : System.Web.Services.Protocols.SoapHeader
    {
        public string UserName;
        public string Password;
    }

    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/", Description="SOAP Header Example")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    public class Service1 : System.Web.Services.WebService
    {
        public AuthHeader curUser;  // header item

        [WebMethod]
        [SoapHeader("curUser")]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [WebMethod(Description = "authenticates a user")]
        [SoapHeader("curUser")]
        bool Login()
        {
            if (curUser != null)
            {
                if (Authenticate(curUser.UserName, curUser.Password))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
                return false;
           
        
        }

        bool Authenticate(string user, string pwd)
        {
            return user == "admin" && pwd == "dotnet";
        }

        [WebMethod(Description = "returns the current time")]
        [SoapHeader("curUser")]
        public string GetCustomerList()
        {
            string customerList = string.Empty;

            if (Login())
                customerList = "OK";
            else
                customerList = "Fail";

            return customerList;
        }

    }
}

PRB: ThreadAbortException Occurs If You Use Response.End, Response.Redirect, or Server.Transfer

Article ID : 312629
Last Review : August 1, 2003
Revision : 2.5
This article was previously published under Q312629

SYMPTOMS

If you use the Response.End, Response.Redirect, or Server.Transfer method, a ThreadAbortException exception occurs. You can use a try-catch statement to catch this exception.

Back to the top

CAUSE

The Response.End method ends the page execution and shifts the execution to the Application_EndRequest event in the application's event pipeline. The line of code that follows Response.End is not executed.

This problem occurs in the Response.Redirect and Server.Transfer methods because both methods call Response.End internally.

Back to the top

RESOLUTION

To work around this problem, use one of the following methods:
For Response.End, call the HttpContext.Current.ApplicationInstance.CompleteRequest method instead of Response.End to bypass the code execution to the Application_EndRequest event.
For Response.Redirect, use an overload, Response.Redirect(String url, bool endResponse) that passes false for the endResponse parameter to suppress the internal call to Response.End. For example:
  Response.Redirect ("nextpage.aspx", false);
						
If you use this workaround, the code that follows Response.Redirect is executed.
For Server.Transfer, use the Server.Execute method instead.

Back to the top

STATUS

This behavior is by design.

Back to the top

ASP.NET MVC Preview 2

ASP.NET MVC Preview 2

http://www.microsoft.com/downloads/details.aspx?FamilyId=38CC4CF1-773A-47E1-8125-BA3369BF54A3&displaylang=en

**How to install on Visual Studio 2008

Visual Studio 2008 command prompt를 실행하여 도스창을 연다
devenv/installvstemplates 입력 후 실행한다

사용준비 끝 VS2008을 실행한다

How to make Windows Service with VS2008

http://blog.naver.com/wildsix/140052467529