I'm working on a few pages on a university website. As such, there are a lot of scripts, stylesheets, images, etc. that I have to pull from places where other people are updating them. All these includes are incorporated into HTML snippets that I'm pulling into an MVC layout page. Problem is, all the paths within those look like this: src="/oit/includes/foo.css">. We use a couple different servers here and there, so I guess that's for portability across servers, subdomains, whatever. That code isn't mine. The point is, when I want to debug my site, it's not going to find localhost:1337/oit/includes... etc. Is there a way to make the debugger think my page is on the university web server, or am I going to have to publish this every time?
I'm using Visual Studio 2012.
You could directly reference the resource from the correct server instead of using relative urls:
<link rel="stylesheet" type="text/css" href="http://someserver/oit/includes/foo.css" />
Related
I have a sharepoint at my office. Its 2013 version. Where I want to write some asp code. But the issue is SharePoint is blocking the code and I am getting error "Code blocks are not allowed in this file". I searched google and found several links to solve the issue by saying make some changes to the webconfig file.
Now my question is how do I find the file. Where it is actually.
What I have is a sharepoint, I don't have any designer. I only have admin access for this site. Can some one please guide me.
I know there are several entries here in stackoverflow, but no one is talking about where to find the file.
Please help me.
My apologies if this happens to be a repetition, in that case please point me to the right post. Thank you guys.
By default injecting server-side code (ASP.NET) in SharePoint pages directly from sites is not allowed for performance reasons, and should remain as is.
If you never approched SP developpment and are not an administrator of the farm in your company I strongly advise you to see first if you can solve your needs with client side development (javascript) instead of going to server side (ASP.NET).
SPS2013 comes with the "Script Editor WebPart" that you can use to inject your custom JS on pages. If you need your custom on all pages consider adding your JS on the site's masterpage.
From JS you can use SharePoint REST API to interact with your site https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service
If you need heavy customisation for your site you can move to the addin model (client side) that will require Visual Studio IDE develoment suite.
And last option is if you explicitly require serve side code and/or need to develop a scalable enterprise grade solution, you will need to make a "SharePoint full trust solution package".
PS: You may see articles around about "SharePoint Framework" (aka SPFx), unfortunatly this is not available for SPS2013.
I am not sure why when I place the web app on the MS server 2008 R2 that it is not reading the style sheets on any pages.
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<link href="/styles/StyleSheet1.css" type="text/css" rel="stylesheet" />
The masterpage has no styles on it or anything on it except the ToolkitScriptManager. I placed it there for future use if needed.
Viewing the source shows the style links there and if I take a link and past it in the url the style sheet appears, so yes, it's there on the server.
http://serverName/WebAppName/styles/StyleSheet1.css
This occurs in all browsers.
The styles are being read in Visual Studio 2010 when debugging.
I tried placing a tilde (~) in front of the reference
link href="~/styles.....
This had no effect.
I tried removing the first forward slash even though I knew this was wrong.
I have been through the server configurations but with no luck.
I there a configuration in the server I am missing? It's been about two years since I had to do any configurations but it is nice to have access to the servers once again.
Thanks for any responses...
After doing a bit of research I found the answer and wanted to post it for a reference to others.
Yes, the link to the css file was broken after testing with Firebug.
Why was it broken? It was from the server.
When creating a directory in IIS for a new site, there are some choices.
I made the choice to create a new virtual directory under the Default Web Site directory.
Old habits die hard from my .Net 1.0 days.
This means the page was looking for the css folder in the wrong place and the href needed to be changed to href="styles/... without the first forward slash.
But when there are a LOT of pages to make changes, this is not a good idea.
What I did and should have done in the first place was create a NEW web site under the Sites folder in IIS. This way it's not a new Virtual Directory and the relative paths throughout the site are now correct.
I hope this post helps someone else in the future.
Thanks for all the replies and suggestions!!!
I have a security problem in my website. A script code was added into my all pages like "<script src="Ip address/viewpic.asp"></script>" . It is between </head> and <body> tag. Now Google says "this site may be hartful for your pc!" about my site. How can i secure my website? I use C# and Visual Studio 2008.
You have been hacked. This code that has been added to your site is trying to hack web browsers that visit your site.
This could have happened a number of ways. The easist thing for you to do is to download an anti-virus like AVG and scan any machines with access to the site. There is malware that looks for FTP connections, it grabs the username/password then logs in and modifies files it finds. You should be using SFTP which can be installed under windows, FTP is only used by people who don't know any better or love to get hacked, or both.
The more complex possibility is that there is a vulnerability in your site. This requires a professional (Like me) to track down and fix. Acunetix can help find flaws in your site, but this might not find the vulnerability that was used to break in.
Edit: Assuming that the script is your own and not malicious:
You should not have any code between </head> and <body> - Otherwise you have got a <script> tag as a direct child of <html> which is not allowed.
Put the <script> tag inside <body> at the correct place where you want the script to execute, to correct the structural issue but you need to provide some more information about the exact error messages you are seeing about security as I'm not aware that Google shows error messages within its search listings and I dont have Google Toolbar installed to know what that does; but I don't believe it has typos in it ;)
So please provide more information about the exact security warnings once you've fixed - and validated (with the W3C Validator) - the structure of your HTML.
Edit: If the script is not intended to be there and has appeared outside of your desire:
Have a look in the HTML source where the script is present; and compare to your own ASPX pages to find out where the script is appearing. If it is being rendered by one of your controls you need to examine where the value is coming from. If it is a database, you need to focus your attention on what gets the information into the DB in the first place. If the script is injected and not into one of your controls then you should talk to your ISP I would think.
I created a website and used css friendly adapters for Menu, TreeView and GridView, all was correct, but after publishing it to my great web server, the menus and treeviews didn't load and there is just some bullets!
Here is my work: http://jds.cot.ir (dead link)
Left side I have a menu which did not load.
Did you copy over the App_Browsers folder? I'd check you copied all files over and, if you can, restart the application pool (touching web.config should achieve this).
I found the problem and the solution, I have an error loading one css file:
<link href="/WebResource.axd?d=FmPs0x8PbK0cHdhnI4N-J7cB33HdEr5UOoA_QzdIwqZdeINM8Kod5dxru5SzZMkL0&t=633820044382031250" type="text/css" rel="stylesheet" />
and the content of this css was an error titled:
Specified argument was out of the range of valid values. Parameter name: utcDate
I changed my pc date to one month ago and rebuilt my solution, and upload it again.
And every thing is correct. ;)
Try deleting precompiled.config from the root of the web app on the server. That did it for me. Haven't really looked into what the pros and cons are. Looks like the publisher's precompilation doesn't take into account the control adapters for some reason. I just ran into this in VS2010 beta 2.
This might sound a little wierd, but all of a sudden the CSS and Javascript files referenced in my master page are not being downloaded while the page is being rendered. I am working on a ASP.NET MVC project and things were all fine like half an hour ago!
Here is what I have in head section of the master page,
<link href="/Content/MyCSS.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
I can see the CSS class intellisense while designing pages. But in the page source I do not see these files being added. I can see the css being applied in the VS designer. I have tried restarting VS, restarting my machine too.
Anyone else faced this situation before. I might go crazy now.
Sounds odd. I would use Microsoft Fiddler to see if that gives you any clues. Also are you using IIS or the built in Web server?
If you are using some kind of source control, you might also want to review your recent changes.
Check that your paths are correct. You can create a web app in a virtual directory off the root, so you path would be "/myapp/default.aspx", in which case your paths for your css and js would be wrong.
Try to avoid putting absolute paths in file references.
You may want to try and remove the leading slash, for example.