오류내용

1. 대용량 다운안됨

2. ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION

 

해결방법

대용량 파일 다운로드 - 버퍼 삭제

크롬계열브라우저 다운안될때 - 파일명을 따옴표로 묶지 않기

 

풀소스

Response.Expires = 0
Response.Clear

Set fs = Server.CreateObject("Scripting.FileSystemObject")
If fs.FileExists("파일풀패스") Then
	user_agent = Request.ServerVariables("HTTP_USER_AGENT")
	'If Instr(user_agent,"Chrome") = 0 Then ' 크로미움이 아닐때만
	'	Response.AddHeader "Content-Disposition", "attachment;filename="""&파일명&""""   '큰따옴표 처리
	'End If
	Response.ContentType = "파일MIME타입"
	Response.AddHeader "Content-Disposition","attachment; filename="&파일명

	Response.AddHeader "Content-Transfer-Encoding","binary"
	Response.AddHeader "Pragma","no-cache"
	Response.AddHeader "Expires","0"
	
	Set objStream = Server.CreateObject("ADODB.Stream")
	objStream.Open
	objStream.Type = 1
	objStream.LoadFromFile "파일풀패스"
	
	Const CHUNK = 2048000
	Response.Buffer = False
	Response.ContentType = fileType
	Do Until objStream.EOS Or Not Response.IsClientConnected
		Response.BinaryWrite(objStream.Read(CHUNK))
	Loop
	objStream.Close
	
	Set strFile = Nothing
	Set objStream = Nothing

Else 
	'파일이 없을 경우...
	Response.Write "해당 파일을 찾을 수 없습니다."
End If

Set fs = Nothing
Response.End

 

 

200메가 넘는 파일도 잘 받아진다

 

항상올림

Function roundUp(x) If x > Int(x) then roundup = Int(x) + 1 Else roundup = x End If 

End Function


숫자 앞에 0으로 채우기

Function PadDigits(n, length)
   PadDigits = Right(String(length,"0") & n, length)
End Function


출처: http://www.albofish.co.uk/2011/03/asp-functions-round-up-leading-zeros/



숫자를 한글로

Function chang_money(money)

        dim num1 ' 한글 숫자 배열

        dim num2 ' 한글 숫자 단위 배열

        dim posNoLevel ' 한글 숫자 단위 출력 위치

        dim tempNo ' 한글 숫자 현재 단위 조립용

        dim strNo ' 한글 숫자 전체 조립용

        dim cntNo ' 변환할 숫자의 길이

        dim posNo ' 변환할 숫자의 현재 변환 위치

        

        num1 = Array("", "일", "이", "삼", "사", "오", "육", "칠", "팔", "구")

        num2 = Array("", "십", "백", "천", "만", "십", "백", "천", "억", "십", "백", "천", "조", "십", "백", "천", "경")

        

        cntNo = Len(money)

        

        ' 숫자가 0 일 경우

        if money = 0 then 

                strNo = "영"

        else

                strNo = ""

                posNoLevel = 0

                posNo = cntNo

                do

                        mo = Cint( Mid(money, posNo, 1) )


                        ' 나머지 값이 0 이 아닐 경우

                        if 0 < mo then

                                tempNo = num1(mo)

                                tempNo = tempNo & num2(posNoLevel)

                                strNo = tempNo & strNo

                        else

                                ' 나머지 값이 0 이면서 10000 단위일때(만, 억, ..)

                                if (posNoLevel Mod 4) = 0 then

                                        strNo = num2(posNoLevel) & strNo

                                end if

                        end if

                        

                        posNoLevel = posNoLevel + 1

                        posNo = posNo - 1

                loop while 0 < posNo

        end if

        

        chang_money = strNo

End Function


출처: http://dumbung.com/main/bbs/board.php?bo_table=ASP_TIP&wr_id=9





'Classic ASP' 카테고리의 다른 글

파일 복사  (0) 2016.11.08
스케쥴러  (0) 2016.09.23
엑셀파일로 다운로드 받기  (2) 2016.06.22
사이트 긁어오기  (0) 2015.08.20
ASP에서 JSON을 쓰려면  (0) 2015.03.06

HTML Table 태그에 내용 넣고 헤더를 고쳐서 엑셀파일인 척해서 다운로드 받기

최상단에 아래 

<%

Response.AddHeader "Content-Disposition","attachment;filename=다운로드 받을 디폴트 파일명.xls"

Response.ContentType = "application/octet-stream"

%>

<table>

<tr>

     <th>컬럼타이틀</th>

</tr>

<tr>

<td>내용</td>

</tr>

</table>



진짜 엑셀파일에 값만 채워넣고 다운로드 받기 - VBScript를 이용해야 한다.

출처: http://stackoverflow.com/questions/24517978/asp-classsic-insert-into-excel-xls-columns-or-create-a-real-excel-format-file

<%@Language=VBScript CodePage=65001%>

<%

    Dim Fso

    Set Fso = Server.CreateObject("Scripting.FileSystemObject")


    Dim emptyXlsFileName

        emptyXlsFileName = Server.Mappath("원본엑셀파일.xlsx") 'empty original file path


    Dim filledXlsFileName

        filledXlsFileName = Replace(Fso.GetTempName, ".tmp", ".xlsx") 'temp file will be created and filled


    Fso.CopyFile emptyXlsFileName, Server.Mappath(filledXlsFileName)

    Dim Connection

    Set Connection = Server.CreateObject("Adodb.Connection") ' 이걸로 해야 오피스가 깔리지 않은 서버에서도 사용 가능하다.

        Connection.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Server.Mappath(filledXlsFileName) & ";Extended Properties=""Excel 12.0;HDR=YES;IMEX=0"";" ' xlsx라 12.0이고 xls면 8.0, 첫열을 타이틀로 할거면 HDR=YES, 아니면 HDR=NO



sql = "select * from [Sheet1$]" ' sheet1 다 불러오기

set objRs = Server.CreateObject("ADODB.Recordset")

objRs.open sql, Connection, 1, 3


rows = 0

do while Not objRs.EOF

if rows = 0 then

objRs.Fields(0).Value = "제목을 제외한 첫번째 줄, 첫번째 컬럼 그러니까 A2"

elseif rows = 1 then 

objRs.Fields(1).Value = "B3"

   objRs.Fields("첫열이 타이틀이었다면 그 컬럼명").Value = "넣을 값"

end if

rows = rows + 1

objRs.MoveNext

loop


objRs.Close

set objRs = Nothing


        Connection.Close

    Set Connection = Nothing


    Const BufferSize = 8192


    Response.ContentType = "application/vnd.ms-excel"

    Response.AddHeader "Content-Disposition", "attachment;filename=다운로드할 디폴트 파일명.xlsx"

    Dim Stm

    Set Stm = Server.CreateObject("Adodb.Stream")

        Stm.Type = 1 'adTypeBinary

        Stm.Open

        Stm.LoadFromFile Server.Mappath(filledXlsFileName)

        Do While Not Stm.EOS

            Response.BinaryWrite Stm.Read(BufferSize)

            Response.Flush

            If Not Response.IsClientConnected Then Exit Do

        Loop

        Stm.Close

    Set Stm = Nothing

    Fso.DeleteFile Server.Mappath(filledXlsFileName)

    Response.End


    Set Fso = Nothing

%>


'Classic ASP' 카테고리의 다른 글

스케쥴러  (0) 2016.09.23
숫자 관련 추가 함수  (0) 2016.06.27
사이트 긁어오기  (0) 2015.08.20
ASP에서 JSON을 쓰려면  (0) 2015.03.06
sleep / delay  (0) 2014.09.12

<%

'페이지로드Post방식

Function getSiteSourcePost( siteURL, params )

 Set httpObj = Server.CreateObject("WinHttp.WinHttpRequest.5.1")

 httpObj.open "POST" , siteURL, False

 httpObj.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"

 '포스트 방식시 위의 라인을 추가해 주어야 한다.

  

 httpObj.Send params

 '포스트의 파라미터는 Send 호출시 같이 값을 넘겨 주어야 한다.

 httpObj.WaitForResponse

 If httpObj.Status = "200" Then

  getSiteSourcePost = httpObj.ResponseText

 Else

  getSiteSourcePost = null

 End If

End Function

 

'페이지로드 get방식

Function getSiteSourceGet( siteURL, params )

 Set httpObj = Server.CreateObject("WinHttp.WinHttpRequest.5.1")

 httpObj.open "GET", siteURL & "?" & params, False

  

 httpObj.Send()

 httpObj.WaitForResponse

 If httpObj.Status = "200" Then

  getSiteSourceGet = httpObj.ResponseText

 Else

  getSiteSourceGet = null

 End If

End Function

 

contents = getSiteSourcePost("사이트주소","")

response.write(contents)

%>


출처: http://2nusa.blogspot.kr/2013/05/class-asp.html

'Classic ASP' 카테고리의 다른 글

숫자 관련 추가 함수  (0) 2016.06.27
엑셀파일로 다운로드 받기  (2) 2016.06.22
ASP에서 JSON을 쓰려면  (0) 2015.03.06
sleep / delay  (0) 2014.09.12
ASP의 컬렉션(Dictionary, Map, 연관배열)  (0) 2014.03.12

1. https://code.google.com/p/aspjson/

2. http://www.aspjson.com/

3. https://github.com/nagaozen/asp-xtreme-evolution/blob/master/lib/axe/classes/Parsers/json2.asp


1의 장점은 사용이 매우 편리하고 직관적임. 다만 output만 지원함.

2의 장점은 json output, input을 둘 다 지원함. 다만 사용법이 번잡스럽고 직관적이지 못함. 비추

3은 json parser. 직관적으로 사용가능하다.


그러므로 1,3을 조합해서 쓰는게 제일 낫다.


'Classic ASP' 카테고리의 다른 글

엑셀파일로 다운로드 받기  (2) 2016.06.22
사이트 긁어오기  (0) 2015.08.20
sleep / delay  (0) 2014.09.12
ASP의 컬렉션(Dictionary, Map, 연관배열)  (0) 2014.03.12
ASP의 배열(Array)  (0) 2014.03.12

오류내용

개발사이트에 접속했더니 브라우저에서 다음과 같이 503 에러가 발생하였다.

HTTP Error 503. The service is unavailable.

 

해결

IIS7 관리자를 켜고 좌측 연결에서 응용 프로그램 풀을 살펴본다. 해당 사이트가 바인딩된 응용프로그램 풀의 상태가 중지되어있을 것이다. 마우스 우클릭해서 시작을 눌러서 잘 시작된거면 좋은 거다. 

만약 바로 다시 종료가 된다면, IIS서버 지우고 재설치하고 이런거 다 의미없다. 

그 종료되는 응용프로그램 풀은 지우고 새로 응용프로그램 풀을 추가한다. 그리고 그 개발 사이트의 고급설정에서 응용 프로그램 풀을 방금 추가한 그 것으로 변경하면 된다.

 

++추가

포트문제를 해결하는 내용이 있어서 나중에 필요할 수 있으므로 기록으로 남겨둔다.

1. 관리자권한으로 커맨드창 실행

2. netsh http show urlacl

3. 중복포트가 보인다면 아래의 코드로 삭제

netsh http delete urlacl url=http://*:포트번호/
netsh http delete urlacl url=http://localhost:포트번호/

 

출처: rohsstory.tistory.com/416

 

        ' sleep 함수

Function Sleep(seconds)

set oShell = CreateObject("Wscript.Shell")

cmd = "%COMSPEC% /c timeout " & seconds & " /nobreak"

oShell.Run cmd,0,1

End Function


        ' 사용예

For i = 1 to 10

response.write("End "&i&"<br>")

Sleep(5)

Next


출처: http://stackoverflow.com/questions/2237393/how-to-delay-a-response-in-classic-asp

'Classic ASP' 카테고리의 다른 글

사이트 긁어오기  (0) 2015.08.20
ASP에서 JSON을 쓰려면  (0) 2015.03.06
ASP의 컬렉션(Dictionary, Map, 연관배열)  (0) 2014.03.12
ASP의 배열(Array)  (0) 2014.03.12
윈도우7에서 ASP(.net 말고) 설치  (0) 2013.03.11

에러내용

An error occurred on the server when processing the URL. Please contact the system administrator.

If you are the system administrator please click here to find out more about this error.


해결

이렇게 하면 적절한 에러메시지가 브라우저에 출력된다.



+ Recent posts