0
일부 사용자가 png, jpeg, gif 및 기타와 같은 확장명을 가진 이미지 파일에 액세스 할 때 httphandler를 실행하고 싶습니다. 하지만 나는 경로를하려고 할 때 404 오류가 발생합니다. 나는 서버가 디스크에서 파일을 찾으려고하지만, 내 처리기에서 파일에 액세스하고 진짜 phisical 파일 경로에 대해 새로운 액세스를 사용하고 싶습니다.
예제 설정 파일 :asp.net 응용 프로그램에서 http 처리기를 실행하지 않습니다.
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpHandlers>
<add verb="GET,HEAD" path="*.jpg" type="Startup.Shop.ImageHandler, Startup.Shop" validate="false"/>
</httpHandlers>
<authorization>
<allow users="*" />
</authorization>
</system.web>
<system.webServer>
<handlers>
<add name="ImageHandlerfor JPG" path="*.jpg" verb="GET" type="Startup.Shop.ImageHandler, Startup.Shop" resourceType="Unspecified" />
<add name="ImageHandler for GIF" path="*.gif" verb="GET" type="Startup.Shop.ImageHandler, Startup.Shop" resourceType="Unspecified" />
<add name="ImageHandler for BMP" path="*.bmp" verb="GET" type="Startup.Shop.ImageHandler, Startup.Shop" resourceType="Unspecified" />
<add name="ImageHandler for PNG" path="*.png" verb="GET" type="Startup.Shop.ImageHandler, Startup.Shop" resourceType="Unspecified" />
</handlers>
</system.webServer>
/configuration>
예 핸들러 클래스 :
public class ImageHandler : IHttpHandler, IRouteHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
public bool IsReusable
{
get
{
return false;
}
}
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
return this;
}
}
그리고 더이 - 당신이 클래식 모드에있는 경우 서버 클래식 모드
예, 서버 설정에 대한 추가를 잊어 버렸습니다. 처리기 매핑에 ImageHandler라는 다음 처리기가 있고 설정 : 요청 경로 : * .png, * .jpeg, * .jpg, * .gif 실행 파일 : C : \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ aspnet_isapi .dll, 모든 동사와 경로 유형 : 알 수 없음 – martmartius
이것이 효과가 있다면 답을 표시해주세요. – Paul