Is there a ready-made solution in ASP.NET Core for publishing log files in browser? This would help developers/testers since they don't always have access to logs on the server. This would of course need to be disabled in production.
I don't believe there are any ready-made tools for this type of request (At least not in any of the documentation I have read).
You could use an AJAX call to the server to retrieve the log file contents and then set them to an HTML element of your choice.
var url = #Url.Action("GetLogFile", "Controller");
$.ajax({
type: "POST",
url: url,
data: logLocation,
success: function(data) {
$(".result").html(data);
}
});
<div class="result"></div>
Obviously you can use what ever HTML element you want, as a div isn't the best display option. I haven't tested this code but it gives you the idea.
Hope this helps!
Related
In my ASP.NET app I am using Jquery datatables plugin like this:
<script type="text/javascript">
$('#grdData').DataTable({
"language": { "url": "Scripts/json/table-language.json" }
});
</script>
when running this on localhost it works fine and it fetches the json file.
But in production I get a 404 not found error.
I guess it somehow relates to relative path...
any ideas on how to fix the path so it would work?
I found the problem.
It was related to IIS, I needed to add Mime Type of .json extension and it did the trick.
Can use way '../data/dataTables/german.json'
How to add the discussion forum in existing application?
Configured with the my application running in WAS and using java snippets i can able to get connected to the connections and get the response .
But with javascript snippets there is a problem .Unable to configure SBT JS and run javascript snippets.
https://localhost:9443/sbt/WebContent/js/sdk/sbt/connections/ForumService is not found
always 404 error in web console.
please help me out
thanks in advance
You should make sure you have the sbt.web project on your server. It sounds like the ForumsService dojo file isn't found.
Also make sure that your managed-beans.xml file is configured, and set properly to point to your connections server.
Here is a snippet which shows the path invocation for ForumService. You can see many more examples in the GitHub Project and reference the wiki which describes your first JS App http://www-10.lotus.com/ldd/appdevwiki.nsf/xpDocViewer.xsp?lookupName=SDK+docs#action=openDocument&res_title=Adding_the_SDK_to_your_web_application_SDK1.0&content=sdkcontent
require(["sbt/connections/ForumService", "sbt/dom", "sbt/json"],
function(ForumService, dom, json) {
var forumService = new ForumService();
var forumUuid = "%{name=ForumService.forumUuid}";
var promise = forumService.getForum(forumUuid);
promise.then(
function(forum) {
dom.setText("json", json.jsonBeanStringify(forum));
},
function(error) {
dom.setText("json", json.jsonBeanStringify(error));
}
);
}
);
I have a Meteor site with Iron-Router. When I use Google's webmaster tools and "fetch as Google", it comes up with an empty body.
Reading Google's documentation on how to make the application crawlable, I believe I need to add a meta tag and return a plain html version of the page if the GET parameter ?_escaped_fragment= is sent.
Is there a simple way to do this with Iron-Router? I have tried diverting the browser to a different template if the GET parameter is present, eg:
Router.map(function () {
this.route('home', {
path: '/',
template: 'home',
onBeforeAction: function () {
if (this.params['_escaped_fragment']=='') {
this.route.options.template = 'another_page';
}
},
});
});
However, this just substitutes another template using javascript, which Google won't see either. Is there a way to provide a plain html file if a specific GET parameter is provided?
Add the spiderable package to your project:
meteor add spiderable
This will automatically add the correct <meta> tag to your page, and spiders will be served a PhantomJS-generated version of your site.
Note that the Google Webmaster tools will still show the empty AJAX version of your page in the crawl results, but Google will crawl and index your page correctly. This appears to be a bug in the Webmaster tools. You can verify that the app was successfully crawled by going to your Webmaster tools homepage (where the list of your websites is). Your website should have a screenshot showing what the Google crawler actually saw.
There is a typo:
if (this.params['_escaped_fragment']=='') {
should be
if (this.params['_escaped_fragment_']=='') {
You missed an underscore.
My app is using a SignalR 1.1.2 on ASP.NET MVC
It has the following call in the View
This uses the auto-generated hub.
At this point all client and server side methods are done.
Can I get a copy of the 'hubs.js' file I get when I paste this
link into the browser.
I want to add a new javascript file to the BundleConfig.cs so I
can minify this file and try and improve the performance of my app.
Hope someone can advise, I have done it and it seems to work, I just
want to be sure that I will not loose the ability to shift gears to
websockets, SSE, Forever-Frame depending on what the client and server
can negotiate.
MVC web optimization does not support dynamic scripts. I did it like this in my last project, it doesnt help with minifying but you can add the static script to the bundle config
(function ($) {
var dynamicScripts = ["signalr/hubs", "eventAggregation/events"];
$.each(dynamicScripts, function () {
$.ajax({
url: this,
cache: true,
dataType: "script",
async: false
});
});
} (jQuery));
if you navigate to the /signalr/hubs uri you can save this javascript file and put it in a bundle. Of course if you change anything to do with signalr then it might not work. But this is for release. Just a note that this 1.1.2
Here is my desired flow:
A static web page (html) uses XHR calls to an ASP.NET page
The .NET page retrieves information from a remote server using web services
The .NET page returns an HTML "snippet" that is inserted into the static HTML page
I'm getting hung up on how to deal with the HTML snippet generation on the .NET (2.0) page. I've thought about something like this in a generic .ashx page:
public void ProcessRequest (HttpContext context)
{
context.Response.Write("<ul>");
//assume "people" is a list of data coming from the external web service
foreach (string person in people)
{
context.Response.Write("<li>" + person + "</li>");
}
context.Response.Write("</ul>");
}
It just seems a big "ugly". Has anyone done this another - and possibly more efficient/elegant - way? Any help would be appreciated.
Returning html for this task is a bit weird, IMO. In most times I prefer the following way. Open your web service to public or add a wrapper to it and just use it directly from js of your static page. The service should return json (preferable) or xml data. On the client side format (print in html as you want) received data using js in callback to the XHR and inject anywhere you want.
But also I want to cast YAGNI on this task - if it'll be used only several times and in a few pages, use the most fastest way to implement it. But if you are building some RIA application I recommend you to check ExtJS javascript library.
Edit 26/02:
If you can't use ASP.NET MVC but wanna to use some good framework instead of "Response.Write" stuff please check OpenRasta. It's one of my favorite web frameworks. It works fine on .Net 2.0 and it's very flexible and powerful. And also it has a great community.