首页 > 其他 > 详细

在IIS6.0以上版本发布Ajax中,解决添加.v路径找不到的问题?

时间:2014-03-17 23:53:58      阅读:950      评论:0      收藏:0      [点我收藏+]

问题描述:配置Aiax方式如下:

1.在AppCode中加入文件夹Ajax,加入两个类文件:

  Ajax.cs:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Web.SessionState;
 
/// <summary>
///Ajax 的摘要说明
/// </summary>
public interface IAjax : IHttpHandler, System.Web.SessionState.IReadOnlySessionState
{
    void ProcessAjax();
    HttpRequest Request { get; }
    HttpSessionState Session { get; }
    HttpResponse Response { get; }
    HttpServerUtility Server { get; }
}
 
public abstract class Ajax : IAjax
{
    #region IAjax 成员
 
    public abstract void ProcessAjax();
    private HttpRequest request;
    public HttpRequest Request
    {
        get { return this.request; }
    }
 
    private HttpResponse response;
    public HttpResponse Response
    {
        get { return this.response; }
    }
 
    private HttpSessionState session;
    public HttpSessionState Session
    {
        get { return this.session; }
    }
 
    private HttpServerUtility server;
    public HttpServerUtility Server
    {
        get { return this.server; }
    }
 
 
    #endregion
 
    #region IHttpHandler 成员
    public bool IsReusable
    {
        get { return true; }
    }
 
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "application/json; charset=utf-8";
        context.Response.ContentEncoding = Encoding.UTF8;
        context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        this.request = context.Request;
        this.response = context.Response;
        this.server = context.Server;
        this.session = context.Session;
        ProcessAjax();
    }
    #endregion
}

 AjaxText.cs:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Web.SessionState;
 
/// <summary>
/// Summary description for AjaxText
/// </summary>
public abstract class AjaxText : IAjax
{
    #region IAjax 成员
 
    public abstract void ProcessAjax();
    private HttpRequest request;
    public HttpRequest Request
    {
        get { return this.request; }
    }
 
    private HttpResponse response;
    public HttpResponse Response
    {
        get { return this.response; }
    }
 
    private HttpSessionState session;
    public HttpSessionState Session
    {
        get { return this.session; }
    }
 
    private HttpServerUtility server;
    public HttpServerUtility Server
    {
        get { return this.server; }
    }
 
 
    #endregion
 
    #region IHttpHandler 成员
    public bool IsReusable
    {
        get { return true; }
    }
 
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain; charset=utf-8";
        context.Response.ContentEncoding = Encoding.UTF8;
        context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        this.request = context.Request;
        this.response = context.Response;
        this.server = context.Server;
        this.session = context.Session;
        ProcessAjax();
    }
    #endregion 
}

 加入Web.HttpHandlers.config:

1
2
3
4
<?xml version="1.0" encoding="utf-8"?>
<httpHandlers>
  <add verb="GET,POST" path="ajaxSupplier.v" type="AjaxSupplier"/>  //type必须和调用的Ajax方法类一样
</httpHandlers>

ajax调用方式:bubuko.com,布布扣

 

在IIS6.0的配置,只需要在bubuko.com,布布扣中加入应用程序扩展即可,但是在IIS7.0以上的版本后,这样的解决方案一直都是提示找不到.v文件

解决该问题的方案:

 1.可删除掉Web.HttpHandlers.config文件,在Web.config文件中加入节点:system.webServer(两种配置方式),具体内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
///可以是这样<br>  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
   <span style="color: rgb(0, 0, 0);"> <defaultDocument>
      <files>
        <remove value="iisstart.htm" />
        <remove value="index.html" />
        <remove value="index.htm" />
        <remove value="Default.asp" />
        <remove value="Default.htm" />
      </files>
    </defaultDocument>
    <security>
      <requestFiltering>
        <fileExtensions>
          <add fileExtension=".v" allowed="true" />
        </fileExtensions>
      </requestFiltering>
    </security></span>
    <handlers>
      <add name="AjaxTest" path="ajaxtest.v" verb="GET,POST" type="AjaxTest"/>
    </handlers>
  </system.webServer>
1
2
3
4
5
6
///也可以是这样<br>  <system.webServer>
  <validation validateIntegratedModeConfiguration="false" />
  <handlers>
    <add name="AjaxTest" path="ajaxtest.v" verb="GET,POST" type="AjaxTest"/>
  </handlers>
</system.webServer>

 

  

在IIS6.0以上版本发布Ajax中,解决添加.v路径找不到的问题?,布布扣,bubuko.com

在IIS6.0以上版本发布Ajax中,解决添加.v路径找不到的问题?

原文:http://www.cnblogs.com/xingvskong11/p/3605611.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!