简体   繁体   中英

How to execute javascript from c# in asp.net

I am working on asp.net mvc app in which i have to perform CRON job to execute this:

==> I have to execute webpage of my application (which contains ajax request) after every two mins. It like tracking someone time to time.

(it is basically executing google map api so usage of javascript is compulsory)

I am wondering how to execute webpage containing javascript same as we execute on browser. I m invoking Application_BeginRequest function in MVC that is called by cron job after every two mins. So how to execute demo page containing javascript.

I have searched alot but did'nt find any useful resources.

Edit: Working of application:

1- CRON job calls Application_Begin function after every two mins

2- Then i want to call DemoPage which contains javascript and ajax request. first when Demo page requested, ajax call made to server which returns some data 3. Then from ajax success, i execute response data with some other data using javascript google map api ( with RouteBox, locating latlng on route ).

3- If point is not in route, it will send alert email.

Its little difficult to explain what i want, but i guess you got my point ?

MORE DETAILS:

When page requested, it returns json string of route, and i have list of latlngs which i need to test against that json string which is done by RouteBox class written in javascritp.

You can return script from your controller:

public ActionResult SampleAction()
        {
            return JavaScript("alert(Sample!');");
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM