问题列表 - 第48084页

如何在ASP.NET MVC中基于每个用户删除输出缓存?

我正在使用VaryByCustom每个浏览器和每个用户创建一个输出缓存:

[OutputCache(Duration = 6000, VaryByParam = "*", VaryByCustom="browser;userName")]
Run Code Online (Sandbox Code Playgroud)

(我已经覆盖GetVaryByCustomString()了这项工作.)

我需要能够删除单个用户的输出缓存,如果可能的话,不会使不同用户的输出缓存失效.我已经读过HttpResponse.RemoveOutputCacheItem(),但这可以通过删除基于路径的输出缓存来实现.有没有办法根据VaryByCustom字符串执行此操作?

c# asp.net-mvc caching asp.net-mvc-3

5
推荐指数
1
解决办法
1540
查看次数

奇怪的node.js错误:TypeError:对象#<Object>没有方法'on'

我正在尝试在node.js中运行一个简单的屏幕抓取应用程序.代码发布在这里:https : //github.com/anismiles/jsdom-based-screen-scraper http://anismiles.wordpress.com/2010/11/29/node-js-and-jquery-to-scrape -websites /

服务器启动正常,但是当我对它运行查询时,我收到以下错误.有谁知道那是为什么?

TypeError: Object #<Object> has no method 'on'
    at Object.<anonymous> (/Users/avishai/Downloads/anismiles-jsdom-based-screen-scraper-f0c79d3/searcher-server.js:9:10)
    at param (/Users/avishai/.node_libraries/.npm/connect/0.5.10/package/lib/connect/middleware/router.js:146:21)
    at param (/Users/avishai/.node_libraries/.npm/connect/0.5.10/package/lib/connect/middleware/router.js:157:15)
    at pass (/Users/avishai/.node_libraries/.npm/connect/0.5.10/package/lib/connect/middleware/router.js:162:10)
    at Object.router [as handle] (/Users/avishai/.node_libraries/.npm/connect/0.5.10/package/lib/connect/middleware/router.js:168:6)
    at next (/Users/avishai/.node_libraries/.npm/connect/0.5.10/package/lib/connect/index.js:218:15)
    at Server.handle (/Users/avishai/.node_libraries/.npm/connect/0.5.10/package/lib/connect/index.js:231:3)
    at Server.emit (events.js:45:17)
    at HTTPParser.onIncoming (http.js:1078:12)
    at HTTPParser.onHeadersComplete (http.js:87:31)
Run Code Online (Sandbox Code Playgroud)

似乎抛出错误的函数是:

function books(app){
    app.get('/:query', function(req, res, next) {

        res.writeHead(200, { 'Content-Type': 'text/html' });

        var rediff = require('./searcher-rediff');
        rediff.on('on_book', function(item){
            res.write(item + "<br/>");
        });
        rediff.on('completed', function(){
            res.end();
        });
        rediff.search(escape(req.params.query));

    });
}
Run Code Online (Sandbox Code Playgroud)

UPDATE

现在我注意到在第一次请求时,我得到了这个:

SyntaxError: …
Run Code Online (Sandbox Code Playgroud)

javascript screen-scraping connect node.js

5
推荐指数
1
解决办法
1万
查看次数

[done] notifyDataSetChanged()不会自动更新ListActivity

我在使用BaseAdapter的notifyDataSetChanged()时遇到了一些麻烦.此方法在refreshItems()中调用,并将更新ListActivity的BaseAdapter.在调用notifyDataSetChanged()之前没有任何反应,直到我使用箭头键向下滚动ListView.不知怎的,修改后的getView()方法也没有被调用.也许你可以给我一个提示 - 谢谢!:)

public class WinampControlClientPlaylist extends ListActivity {

static WinampControlClientPlaylist activity = null;

static EfficientAdapter adapter = null;


static class EfficientAdapter extends BaseAdapter {


    public EfficientAdapter(Context context) {
        mInflater = LayoutInflater.from(context);
    }

    private LayoutInflater mInflater;

    @Override
    public int getCount() {
        return Settings.playlistlength;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder;


        if (convertView == null) 
        {
            holder = new ViewHolder();

            convertView = mInflater.inflate(R.layout.listview, null);

            holder.text …
Run Code Online (Sandbox Code Playgroud)

android

8
推荐指数
2
解决办法
2万
查看次数

修改过的文件出现在Git但没有更新的问题?

我有一些文件/文件夹只是不会离开Git临时区域?

# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#   (commit or discard the untracked or modified content in submodules)
#
#   modified:   JavaScript/Stand.ard.iz.er (modified content, untracked content)
#   modified:   Site (untracked content)
#   modified:   Template Archives/Template (modified content, untracked content)
#   modified:   Template Archives/Template_Git (modified content, untracked content)
#
Run Code Online (Sandbox Code Playgroud)

我已经尝试了所有这些"修改"的文件,但没有运气?

我试过了...

git add .
git …
Run Code Online (Sandbox Code Playgroud)

git staging git-submodules

9
推荐指数
2
解决办法
7442
查看次数

ruby中二进制搜索算法的问题

def binarysearch(a, b,  tofind, stringarray)
  k=(a+b)/2
  if a==b
    return nil
  end
  if (stringarray[k]).include? tofind
    return stringarray[k]
  end
  if (stringarray[k]<=>tofind)==1
    binarysearch(a,k,tofind,stringarray)
  end
  if (stringarray[k]<=>tofind)==-1
    binarysearch(k,b,tofind,stringarray)
  end
  if (stringarray[k]<=>tofind)==0
    return stringarray[k]
  end
end
Run Code Online (Sandbox Code Playgroud)

这是一种二进制搜索算法.a和b是它正在处理的数组索引,tofind是它正在搜索的字符串,而stringarray是一个字符串数组.不幸的是,每次我尝试运行此函数时,我都会收到以下语法错误:

undefined method `include?' for 1:Fixnum (NoMethodError)`
Run Code Online (Sandbox Code Playgroud)

但这不是一个固定点.我是Ruby的新手,所以我很容易错过一些明显的东西.有什么建议?

这是我声明stringarray的地方:( Netbeans说它是一个数组)

  strings=Array.new
  newstring=""
  until newstring=="no" do
    newstring=gets.chomp
    strings[strings.size]=newstring
  end
Run Code Online (Sandbox Code Playgroud)

ruby arrays binary-search

0
推荐指数
1
解决办法
2498
查看次数

使用gcc/g ++时抑制系统调用

我在我的大学局域网中有一个门户网站,人们可以将代码上传到C/C++中的编程难题.我想使门户网站安全,以便人们无法通过提交的代​​码进行系统调用.可能有几种解决方法,但我想知道我是否可以通过设置一些聪明的gcc标志来做到这一点.默认情况下<unistd.h>,libc似乎包含,它似乎是声明系统调用的基本文件.有没有办法告诉gcc/g ++在编译时'忽略'这个文件,这样unistd.h中声明的所有函数都不能被访问?

linux gcc g++

7
推荐指数
1
解决办法
358
查看次数

在python中下载文件

当我想用这段代码在python中下载jpeg:

def download(url, dest):
    s = urllib2.urlopen(url)
    content = s.read()
    s.close()
    d = open(dest,'w')
    d.write(content)
    d.close()
Run Code Online (Sandbox Code Playgroud)

hdd上的文件是不可读的,但是当我在mozilla中打开jpeg时,我可以使用windows和python 2.6的一些解决方案吗?谢谢

python download

2
推荐指数
3
解决办法
1802
查看次数

在C#(3.0)中使用条件(?:)运算符进行方法选择?

我正在重构一些代码.

现在有很多地方有这样的功能:

string error;
if (a) {
   error = f1(a, long, parameter, list);
}
else {
   error = f2(the_same, long, parameter, list);
}
Run Code Online (Sandbox Code Playgroud)

在重构f1和f2之前(虽然很大,但做类似的事情),我想重构为:

string error = (a ? f1 : f2)(a, long, parameter, list);
Run Code Online (Sandbox Code Playgroud)

就像在C中一样.(函数签名是相同的)

但是我收到一个错误:

"错误13无法确定条件表达式的类型,因为'方法组'和'方法组'之间没有隐式转换"

这将允许我通过初始重构给出不变行为来识别参数列表是相同的,并且还在单个位置重构调用,确保在这些各种重构期间所有内容都没有因为我将调用接口更改为方法而被破坏.

我错过了一些小的东西,它允许接近这个的语法工作(而不是一大堆额外的委托类型定义等)?

抱歉编辑,但实际上有一个返回值,是的,不幸的是,它是一个字符串.;-(

现在,我正在解决这个问题:

string error = a ? f1(a, long, parameter, list) : f2(a, long, parameter, list);
Run Code Online (Sandbox Code Playgroud)

问题是参数列表确实很长,并且会被重构,我宁愿先将它们合并,并在我更改时处理编译器错误.

.net c# .net-3.5

23
推荐指数
4
解决办法
7439
查看次数

从Query中设置表单域的值

我有一个表单域,其中一个值具有在应用程序设置表中定义的默认值.用户将在显示创建表单时看到默认值,但如果在保存新行之前需要将其更改为其他值.

我在字段默认情况下没有看到任何方式指定默认值是SQL查询的结果(例如,从app_defaults中选择default_rate,其中row_key = 1).

当然这必须是可能的,但是怎么样?

oracle oracle-apex

4
推荐指数
1
解决办法
3万
查看次数

用javascript中的Lessthan空间和角色替换Lessthan和角色

在我的文本框中,我应该找到(<LessThan Symobl> <character>)并替换为(<LessThan Symbol <space> <character>)

例:

输入:

abc<xyz abc <abc
Run Code Online (Sandbox Code Playgroud)

输出:

abc< xyz abc < abc
Run Code Online (Sandbox Code Playgroud)

从字符串中,我应该找到([LessThanSymbol] [character])并在javascript中替换为([LessThanSymbol] [space] [Character])

javascript

2
推荐指数
1
解决办法
3111
查看次数