[英]how to store json file at server using asp.net as server side language and how to access json data using javascript, html and css?
I am a newbie in web development. 我是网络开发的新手。 I am in the process of building a food blog website.
我正在建立一个美食博客网站。 I want to pursue front-end-web-developer career.
我想追求前端网络开发人员的职业生涯。 I have built my website only using client side languages like javascript, jquery, html and css.
我只使用javascript,jquery,html和css等客户端语言构建了我的网站。 I have used json to store the data.
我用json来存储数据。 my questions are -
我的问题是 -
1. I now want to make my website live. 我现在想让我的网站上线。 For that I want my website to be hosted on server.
为此,我希望我的网站托管在服务器上。 As I am not using any server side scripting, would my data related to website be visible to everyone if they do try to "inspect element" or "view source"?
由于我没有使用任何服务器端脚本,如果他们确实尝试“检查元素”或“查看源代码”,我的每个人都可以看到与网站相关的数据吗?
2. how can I separate Json from client side code/scripting? 2.如何将Json与客户端代码/脚本分开? I think for that I will have to seperate json data from other javascript code and store it into a separate file on a server.
我认为,我将不得不从其他javascript代码中分离json数据并将其存储在服务器上的单独文件中。 But in that case how can I access the Json data?
但在这种情况下,我如何访问Json数据? For that I will have to make use of some server side scripting language.
为此,我将不得不使用一些服务器端脚本语言。 I prefer Asp.net(not that I know asp.net but I am familiar with C# hence).
我更喜欢Asp.net(不是我认识asp.net,但我熟悉C#)。 I also would have to make changes to my html code at client side to fetch the Json data from server.
我还必须在客户端更改我的html代码以从服务器获取Json数据。 I am not really aware of this whole thing.
我并不是真的意识到这一切。 Could someone spare some time and let me know how to go about it?
有人可以节省一些时间让我知道如何去做吗?
3. Does all the client side and server side code lies in a single asp.net project? 3.所有客户端和服务器端代码都在一个asp.net项目中吗?
I have searched over internet. 我在网上搜索过。 Mostly all the material/coding available over internet is mostly in php or python hence I am confused.
通常互联网上的所有材料/编码大部分是在php或python中,因此我很困惑。 There no definite guideline that I could find as how to handle the data part only using JSON?
没有明确的指导我可以找到如何只使用JSON处理数据部分?
to help you answer your 2nd question 2. how can I separate Json from client side code/scripting? 帮助您回答第二个问题2.如何将Json与客户端代码/脚本分开? usually server side is in the controller so your HomeController.cs for instance will have an Index action (public ActionResult Index()) that method will basically be called whenever the browser hits the route Home/Index.cshtml in order to separate these two, you may fetch or construct your Json in the controller and pass it to the ViewBag, from there you can access it in the view.
通常服务器端在控制器中,所以你的HomeController.cs会有一个Index动作(公共ActionResult Index()),只要浏览器到达Home / Index.cshtml路由以便将这两个分开,基本上就会调用该方法,您可以在控制器中获取或构建Json并将其传递给ViewBag,然后您可以在视图中访问它。 using $.ajax will help as well to get the json from the view and update the content of a specific part of your page for instance.
使用$ .ajax也可以帮助从视图中获取json并更新页面特定部分的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.