In this report, we present a mesoporous carbon nanosphere that can target drugs to tumors and image tumor biomarkers. A single-strand DNA (P-0 aptamer) aptavalve was capped on the surface of doxorubicin-loaded oxide mesoporous carbon nanospheres (Dox-OMCN-P-0) through p-p stacking for real-time imaging-guided on-demand targeting drug delivery. The Dox-OMCN-P-0 could not only realize the detection of MUC1 tumor marker with a wide linear range (0.1 - 10.6 mu mol/L) and a low detection limit (17.5 nmol) based on different apparatuses, but also achieve in-situ targeting imaging of cellular MUC1 concentration in vitro and in vivo via "off-on" fluorescence biosensing. Much attractively, as a real-time feedback of the diagnostic/imaging outcomes, Dox-OMCN-P-0 accomplished the on-demand targeting drug delivery in quantitative response to MUC1. Controllable chemotherapy with sustained release and pH-sensitiveness, together with the potential photothermal therapy, were also clearly demonstrated. This is a simple but advanced platform, which could well achieve the real-time switchable imaging of cellular mucin for targeting cancer therapy.